##// END OF EJS Templates
check-code: build translation table for repquote in global for efficiency...
FUJIWARA Katsunori -
r29398:2a54cf92 default
parent child Browse files
Show More
@@ -50,25 +50,26 b' def compilere(pat, multiline=False):'
50 50 pass
51 51 return re.compile(pat)
52 52
53 # check "rules depending on implementation of repquote()" in each
54 # patterns (especially pypats), before changing around repquote()
55 _repquotefixedmap = {' ': ' ', '\n': '\n', '.': 'p', ':': 'q',
56 '%': '%', '\\': 'b', '*': 'A', '+': 'P', '-': 'M'}
57 def _repquoteencodechr(i):
58 if i > 255:
59 return 'u'
60 c = chr(i)
61 if c in _repquotefixedmap:
62 return _repquotefixedmap[c]
63 if c.isalpha():
64 return 'x'
65 if c.isdigit():
66 return 'n'
67 return 'o'
68 _repquotett = ''.join(_repquoteencodechr(i) for i in xrange(256))
69
53 70 def repquote(m):
54 # check "rules depending on implementation of repquote()" in each
55 # patterns (especially pypats), before changing this function
56 fixedmap = {' ': ' ', '\n': '\n', '.': 'p', ':': 'q',
57 '%': '%', '\\': 'b', '*': 'A', '+': 'P', '-': 'M'}
58 def encodechr(i):
59 if i > 255:
60 return 'u'
61 c = chr(i)
62 if c in fixedmap:
63 return fixedmap[c]
64 if c.isalpha():
65 return 'x'
66 if c.isdigit():
67 return 'n'
68 return 'o'
69 71 t = m.group('text')
70 tt = ''.join(encodechr(i) for i in xrange(256))
71 t = t.translate(tt)
72 t = t.translate(_repquotett)
72 73 return m.group('quote') + t + m.group('quote')
73 74
74 75 def reppython(m):
@@ -276,7 +276,11 b' web templates'
276 276 > ''' "%-6d \n 123456 .:*+-= foobar")
277 277 > EOF
278 278
279 $ "$check_code" stringjoin.py
279 (Checking multiple invalid files at once examines whether caching
280 translation table for repquote() works as expected or not. All files
281 should break rules depending on result of repquote(), in this case)
282
283 $ "$check_code" stringjoin.py uigettext.py
280 284 stringjoin.py:1:
281 285 > foo = (' foo'
282 286 string join across lines with no space
@@ -301,9 +305,6 b' web templates'
301 305 stringjoin.py:8:
302 306 > 'bar foo-'
303 307 string join across lines with no space
304 [1]
305
306 $ "$check_code" uigettext.py
307 308 uigettext.py:1:
308 309 > ui.status("% 10s %05d % -3.2f %*s %%"
309 310 missing _() in ui message (use () to hide false-positives)
General Comments 0
You need to be logged in to leave comments. Login now