Files
@ c83f4a4d3aee
Branch filter:
Location: kallithea/scripts/logformat.py - annotation
c83f4a4d3aee
1.7 KiB
text/x-python
i18n: el: fix syntax errors
Weblate reports:
msgmerge --no-wrap --backup=none --previous --update /home/www-data/weblate-hosted/vcs/kallithea/kallithea/kallithea/i18n/el/LC_MESSAGES/kallithea.po /home/www-data/weblate-hosted/vcs/kallithea/kallithea/kallithea/i18n/kallithea.pot
/home/www-data/weblate-hosted/vcs/kallithea/kallithea/kallithea/i18n/el/LC_MESSAGES/kallithea.po:1686: end-of-line within string
/home/www-data/weblate-hosted/vcs/kallithea/kallithea/kallithea/i18n/el/LC_MESSAGES/kallithea.po:1686: keyword "simple" unknown
/home/www-data/weblate-hosted/vcs/kallithea/kallithea/kallithea/i18n/el/LC_MESSAGES/kallithea.po:1686:10: syntax error
/home/www-data/weblate-hosted/vcs/kallithea/kallithea/kallithea/i18n/el/LC_MESSAGES/kallithea.po:1686: keyword "diff" unknown
/home/www-data/weblate-hosted/vcs/kallithea/kallithea/kallithea/i18n/el/LC_MESSAGES/kallithea.po:1687: end-of-line within string
msgmerge: found 5 fatal errors
Problem introduced in commit 880e2f07651b3eaf88d01e71ac7f3cbf88df163c
Weblate reports:
msgmerge --no-wrap --backup=none --previous --update /home/www-data/weblate-hosted/vcs/kallithea/kallithea/kallithea/i18n/el/LC_MESSAGES/kallithea.po /home/www-data/weblate-hosted/vcs/kallithea/kallithea/kallithea/i18n/kallithea.pot
/home/www-data/weblate-hosted/vcs/kallithea/kallithea/kallithea/i18n/el/LC_MESSAGES/kallithea.po:1686: end-of-line within string
/home/www-data/weblate-hosted/vcs/kallithea/kallithea/kallithea/i18n/el/LC_MESSAGES/kallithea.po:1686: keyword "simple" unknown
/home/www-data/weblate-hosted/vcs/kallithea/kallithea/kallithea/i18n/el/LC_MESSAGES/kallithea.po:1686:10: syntax error
/home/www-data/weblate-hosted/vcs/kallithea/kallithea/kallithea/i18n/el/LC_MESSAGES/kallithea.po:1686: keyword "diff" unknown
/home/www-data/weblate-hosted/vcs/kallithea/kallithea/kallithea/i18n/el/LC_MESSAGES/kallithea.po:1687: end-of-line within string
msgmerge: found 5 fatal errors
Problem introduced in commit 880e2f07651b3eaf88d01e71ac7f3cbf88df163c
8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 665dfa112f2c 8bc8366a6874 8bc8366a6874 665dfa112f2c | #!/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 = open(f).read()
for r, t in res:
s = r.sub(t, s)
open(f, 'w').write(s)
|