Mercurial > kallithea
view scripts/logformat.py @ 5878:1658beb26ff9
pull requests: prevent adding DEFAULT user as reviewer
Add a helper method to resolve reviewers, with an added check to prevent
the adding of the DEFAULT user as reviewer.
The __add_reviewers method, although internal, had a troubling interface
where the method was responsible for resolving reviewers, but the caller
was responsible for resolving mention_recipients. The method is changed
to always take two sets of database User objects, leaving the resolution
to the caller in both cases.
author | Søren Løvborg <sorenl@unity3d.com> |
---|---|
date | Wed, 06 Apr 2016 21:47:53 +0200 |
parents | 8bc8366a6874 |
children | 665dfa112f2c |
line wrap: on
line source
#!/usr/bin/env python2 import re import sys if len(sys.argv) < 2: print 'Cleanup of superfluous % formatting of log statements.' print 'Usage:' print ''' hg revert `hg loc '*.py'|grep -v logformat.py` && scripts/logformat.py `hg loc '*.py'` && hg diff''' raise SystemExit(1) logre = r''' (log\.(?:error|info|warning|debug) [(][ \n]* ) %s ( [ \n]*[)] ) ''' res = [ # handle % () - keeping spaces around the old % (re.compile(logre % r'''("[^"]*"|'[^']*') ([\n ]*) % ([\n ]*) \( ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* ) \) ''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'), # handle % without () - keeping spaces around the old % (re.compile(logre % r'''("[^"]*"|'[^']*') ([\n ]*) % ([\n ]*) ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* ) ''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'), # remove extra space if it is on next line (re.compile(logre % r'''("[^"]*"|'[^']*') , (\n [ ]) ([ ][\n ]*) ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* ) ''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'), # remove extra space if it is on same line (re.compile(logre % r'''("[^"]*"|'[^']*') , [ ]+ () ( [\n ]+) ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* ) ''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'), # remove trailing , and space (re.compile(logre % r'''("[^"]*"|'[^']*') , () ( [\n ]*) ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* [^(), \n] ) [ ,]*''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'), ] for f in sys.argv[1:]: s = file(f).read() for r, t in res: s = r.sub(t, s) file(f, 'w').write(s)