Show More
@@ -5,8 +5,15 b'' | |||||
5 | import polib |
|
5 | import polib | |
6 | import re |
|
6 | import re | |
7 |
|
7 | |||
|
8 | scanners = [] | |||
8 | checkers = [] |
|
9 | checkers = [] | |
9 |
|
10 | |||
|
11 | def scanner(): | |||
|
12 | def decorator(func): | |||
|
13 | scanners.append(func) | |||
|
14 | return func | |||
|
15 | return decorator | |||
|
16 | ||||
10 | def levelchecker(level, msgidpat): |
|
17 | def levelchecker(level, msgidpat): | |
11 | def decorator(func): |
|
18 | def decorator(func): | |
12 | if msgidpat: |
|
19 | if msgidpat: | |
@@ -61,6 +68,40 b' def promptchoice(pe):' | |||||
61 | if [c for c, i in indices if len(c) == i + 1]: |
|
68 | if [c for c, i in indices if len(c) == i + 1]: | |
62 | yield "msgstr has invalid '&' followed by none" |
|
69 | yield "msgstr has invalid '&' followed by none" | |
63 |
|
70 | |||
|
71 | deprecatedpe = None | |||
|
72 | @scanner() | |||
|
73 | def deprecatedsetup(pofile): | |||
|
74 | pes = [p for p in pofile if p.msgid == 'DEPRECATED'] | |||
|
75 | if len(pes): | |||
|
76 | global deprecatedpe | |||
|
77 | deprecatedpe = pes[0] | |||
|
78 | ||||
|
79 | @fatalchecker('(DEPRECATED)') | |||
|
80 | def deprecated(pe): | |||
|
81 | """Check for DEPRECATED | |||
|
82 | >>> ped = polib.POEntry( | |||
|
83 | ... msgid = 'DEPRECATED', | |||
|
84 | ... msgstr= 'DETACERPED') | |||
|
85 | >>> deprecatedsetup([ped]) | |||
|
86 | >>> pe = polib.POEntry( | |||
|
87 | ... msgid = 'Something (DEPRECATED)', | |||
|
88 | ... msgstr= 'something (DETACERPED)') | |||
|
89 | >>> match(deprecated, pe) | |||
|
90 | True | |||
|
91 | >>> pe = polib.POEntry( | |||
|
92 | ... msgid = 'Something (DEPRECATED)', | |||
|
93 | ... msgstr= 'something') | |||
|
94 | >>> match(deprecated, pe) | |||
|
95 | True | |||
|
96 | >>> for e in deprecated(pe): print e | |||
|
97 | msgstr inconsistently translated (DEPRECATED) | |||
|
98 | """ | |||
|
99 | global deprecatedpe | |||
|
100 | if not '(DEPRECATED)' in pe.msgstr: | |||
|
101 | if not (deprecatedpe and deprecatedpe.msgstr | |||
|
102 | and deprecatedpe.msgstr in pe.msgstr): | |||
|
103 | yield "msgstr inconsistently translated (DEPRECATED)" | |||
|
104 | ||||
64 | #################### |
|
105 | #################### | |
65 |
|
106 | |||
66 | def warningchecker(msgidpat=None): |
|
107 | def warningchecker(msgidpat=None): | |
@@ -117,6 +158,8 b' def check(pofile, fatal=True, warning=Fa' | |||||
117 | return [] |
|
158 | return [] | |
118 |
|
159 | |||
119 | detected = [] |
|
160 | detected = [] | |
|
161 | for checker in scanners: | |||
|
162 | checker(pofile) | |||
120 | for pe in pofile.translated_entries(): |
|
163 | for pe in pofile.translated_entries(): | |
121 | errors = [] |
|
164 | errors = [] | |
122 | for checker, level in targetcheckers: |
|
165 | for checker, level in targetcheckers: |
General Comments 0
You need to be logged in to leave comments.
Login now