##// END OF EJS Templates
check-code: replace quoted characters correctly...
FUJIWARA Katsunori -
r29276:4dd530df default
parent child Browse files
Show More
@@ -51,22 +51,20 b' def compilere(pat, multiline=False):'
51 return re.compile(pat)
51 return re.compile(pat)
52
52
53 def repquote(m):
53 def repquote(m):
54 fromc = '.:'
54 fixedmap = {'.': 'p', ':': 'q'}
55 tochr = 'pq'
56 def encodechr(i):
55 def encodechr(i):
57 if i > 255:
56 if i > 255:
58 return 'u'
57 return 'u'
59 c = chr(i)
58 c = chr(i)
60 if c in ' \n':
59 if c in ' \n':
61 return c
60 return c
61 if c in fixedmap:
62 return fixedmap[c]
62 if c.isalpha():
63 if c.isalpha():
63 return 'x'
64 return 'x'
64 if c.isdigit():
65 if c.isdigit():
65 return 'n'
66 return 'n'
66 try:
67 return 'o'
67 return tochr[fromc.find(c)]
68 except (ValueError, IndexError):
69 return 'o'
70 t = m.group('text')
68 t = m.group('text')
71 tt = ''.join(encodechr(i) for i in xrange(256))
69 tt = ''.join(encodechr(i) for i in xrange(256))
72 t = t.translate(tt)
70 t = t.translate(tt)
@@ -248,7 +246,7 b' pypats = ['
248 (r'^\s+(\w|\.)+=\w[^,()\n]*$', "missing whitespace in assignment"),
246 (r'^\s+(\w|\.)+=\w[^,()\n]*$', "missing whitespace in assignment"),
249 (r'\w\s=\s\s+\w', "gratuitous whitespace after ="),
247 (r'\w\s=\s\s+\w', "gratuitous whitespace after ="),
250 (r'.{81}', "line too long"),
248 (r'.{81}', "line too long"),
251 (r' x+[xo][\'"]\n\s+[\'"]x', 'string join across lines with no space'),
249 (r' x+[xpqo][\'"]\n\s+[\'"]x', 'string join across lines with no space'),
252 (r'[^\n]\Z', "no trailing newline"),
250 (r'[^\n]\Z', "no trailing newline"),
253 (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"),
251 (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"),
254 # (r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=',
252 # (r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=',
@@ -248,3 +248,27 b' web templates'
248 > {desc|escape}
248 > {desc|escape}
249 warning: follow desc keyword with either firstline or websub
249 warning: follow desc keyword with either firstline or websub
250 [1]
250 [1]
251
252 'string join across lines with no space' detection
253
254 $ cat > stringjoin.py <<EOF
255 > foo = (' foo'
256 > 'bar foo.'
257 > 'bar foo:'
258 > 'bar foo@'
259 > 'bar')
260 > EOF
261 $ "$check_code" stringjoin.py
262 stringjoin.py:1:
263 > foo = (' foo'
264 string join across lines with no space
265 stringjoin.py:2:
266 > 'bar foo.'
267 string join across lines with no space
268 stringjoin.py:3:
269 > 'bar foo:'
270 string join across lines with no space
271 stringjoin.py:4:
272 > 'bar foo@'
273 string join across lines with no space
274 [1]
General Comments 0
You need to be logged in to leave comments. Login now