Show More
@@ -933,8 +933,8 b' class HasPermissionAny(_PermsFunction):' | |||||
933 | global_permissions = request.authuser.permissions['global'] # usually very short |
|
933 | global_permissions = request.authuser.permissions['global'] # usually very short | |
934 | ok = any(p in global_permissions for p in self.required_perms) |
|
934 | ok = any(p in global_permissions for p in self.required_perms) | |
935 |
|
935 | |||
936 |
log.debug('Check %s for global %s (%s): %s' |
|
936 | log.debug('Check %s for global %s (%s): %s', | |
937 |
|
|
937 | request.authuser.username, self.required_perms, purpose, ok) | |
938 | return ok |
|
938 | return ok | |
939 |
|
939 | |||
940 |
|
940 | |||
@@ -983,7 +983,7 b' class HasPermissionAnyMiddleware(object)' | |||||
983 | except KeyError: |
|
983 | except KeyError: | |
984 | ok = False |
|
984 | ok = False | |
985 |
|
985 | |||
986 |
log.debug('Middleware check %s for %s for repo %s (%s): %s' |
|
986 | log.debug('Middleware check %s for %s for repo %s (%s): %s', user.username, self.required_perms, repo_name, purpose, ok) | |
987 | return ok |
|
987 | return ok | |
988 |
|
988 | |||
989 |
|
989 |
@@ -190,7 +190,7 b' class RepoPage(Page):' | |||||
190 | try: |
|
190 | try: | |
191 | self.page = int(page) # make it int() if we get it as a string |
|
191 | self.page = int(page) # make it int() if we get it as a string | |
192 | except (ValueError, TypeError): |
|
192 | except (ValueError, TypeError): | |
193 |
log.error("Invalid page value: %r" |
|
193 | log.error("Invalid page value: %r", page) | |
194 | self.page = 1 |
|
194 | self.page = 1 | |
195 |
|
195 | |||
196 | self.items_per_page = items_per_page |
|
196 | self.items_per_page = items_per_page |
@@ -3,13 +3,6 b'' | |||||
3 | import re |
|
3 | import re | |
4 | import sys |
|
4 | import sys | |
5 |
|
5 | |||
6 | if len(sys.argv) < 2: |
|
|||
7 | print 'Cleanup of superfluous % formatting of log statements.' |
|
|||
8 | print 'Usage:' |
|
|||
9 | print ''' hg revert `hg loc '*.py'|grep -v logformat.py` && scripts/logformat.py `hg loc '*.py'` && hg diff''' |
|
|||
10 | raise SystemExit(1) |
|
|||
11 |
|
||||
12 |
|
||||
13 | logre = r''' |
|
6 | logre = r''' | |
14 | (log\.(?:error|info|warning|debug) |
|
7 | (log\.(?:error|info|warning|debug) | |
15 | [(][ \n]* |
|
8 | [(][ \n]* | |
@@ -19,6 +12,8 b" logre = r'''" | |||||
19 | [ \n]*[)] |
|
12 | [ \n]*[)] | |
20 | ) |
|
13 | ) | |
21 | ''' |
|
14 | ''' | |
|
15 | ||||
|
16 | ||||
22 | res = [ |
|
17 | res = [ | |
23 | # handle % () - keeping spaces around the old % |
|
18 | # handle % () - keeping spaces around the old % | |
24 | (re.compile(logre % r'''("[^"]*"|'[^']*') ([\n ]*) % ([\n ]*) \( ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* ) \) ''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'), |
|
19 | (re.compile(logre % r'''("[^"]*"|'[^']*') ([\n ]*) % ([\n ]*) \( ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* ) \) ''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'), | |
@@ -32,8 +27,20 b' res = [' | |||||
32 | (re.compile(logre % r'''("[^"]*"|'[^']*') , () ( [\n ]*) ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* [^(), \n] ) [ ,]*''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'), |
|
27 | (re.compile(logre % r'''("[^"]*"|'[^']*') , () ( [\n ]*) ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* [^(), \n] ) [ ,]*''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'), | |
33 | ] |
|
28 | ] | |
34 |
|
29 | |||
35 | for f in sys.argv[1:]: |
|
30 | ||
|
31 | def rewrite(f): | |||
36 | s = open(f).read() |
|
32 | s = open(f).read() | |
37 | for r, t in res: |
|
33 | for r, t in res: | |
38 | s = r.sub(t, s) |
|
34 | s = r.sub(t, s) | |
39 | open(f, 'w').write(s) |
|
35 | open(f, 'w').write(s) | |
|
36 | ||||
|
37 | ||||
|
38 | if __name__ == '__main__': | |||
|
39 | if len(sys.argv) < 2: | |||
|
40 | print 'Cleanup of superfluous % formatting of log statements.' | |||
|
41 | print 'Usage:' | |||
|
42 | print ''' hg revert `hg loc '*.py'|grep -v logformat.py` && scripts/logformat.py `hg loc '*.py'` && hg diff''' | |||
|
43 | raise SystemExit(1) | |||
|
44 | ||||
|
45 | for f in sys.argv[1:]: | |||
|
46 | rewrite(f) |
General Comments 0
You need to be logged in to leave comments.
Login now