Loading

Revision differences

Old revision #poaitg1swNew revision #prn4zucqf
1diff -r d4bb7a333937 scripts/nml_langcheck/languages.py  1http://ashematme.ru - ashematme.ru
2--- a/scripts/nml_langcheck/languages.py    Fri Jan 30 13:10:17 2015 +0000    
3+++ b/scripts/nml_langcheck/languages.py    Sat Jan 31 16:10:24 2015 +0000    
4@@ -29,10 +29,10 @@    
5 def make_revline(rev, line):    
6     if rev is None:    
7         if line is None: return None    
8-        return u"Line %d" % line    
9+        return "Line %d" % line    
10     else:    
11         if line is None:    
12-            return u"r%d" % rev    
13+            return "r%d" % rev    
14         return "at line %d, r%d" % (line, rev)    
15     
16     
17@@ -90,34 +90,34 @@    
18         self.old_rev = None    
19     
20     def write(self, fp):    
21-        text = [u'%s:\n' % (self.str_name,)]    
22+        text = ['%s:\n' % (self.str_name,)]    
23         printed = False    
24     
25         if self.trans_text is not None:    
26-            if printed: text.append(u'\n')    
27+            if printed: text.append('\n')    
28             rv = make_revline(self.trans_rev, self.trans_line)    
29             if rv is None:    
30-                text.append(u'\tTranslation: "%s"\n' % self.trans_text)    
31+                text.append('\tTranslation: "%s"\n' % self.trans_text)    
32             else:    
33-                text.append(u'\tTranslation %s: "%s"\n' % (rv, self.trans_text))    
34+                text.append('\tTranslation %s: "%s"\n' % (rv, self.trans_text))    
35             printed = True    
36     
37         if self.master_text is not None:    
38-            if printed: text.append(u'\n')    
39+            if printed: text.append('\n')    
40             rv = make_revline(self.master_rev, self.master_line)    
41             if rv is None:    
42-                text.append(u'\tCurrent source: "%s"\n' % self.master_text)    
43+                text.append('\tCurrent source: "%s"\n' % self.master_text)    
44             else:    
45-                text.append(u'\tCurrent source %s: "%s"\n' % (rv, self.master_text))    
46+                text.append('\tCurrent source %s: "%s"\n' % (rv, self.master_text))    
47             printed = True    
48     
49         if self.old_text is not None:    
50-            if printed: text.append(u'\n')    
51+            if printed: text.append('\n')    
52             rv = make_revline(self.old_rev, None)    
53             if rv is None:    
54-                text.append(u'\tOld source: "%s"\n' % self.old_text)    
55+                text.append('\tOld source: "%s"\n' % self.old_text)    
56             else:    
57-                text.append(u'\tOld source %s: "%s"\n' % (rv, self.old_text))    
58+                text.append('\tOld source %s: "%s"\n' % (rv, self.old_text))    
59             printed = True    
60     
61     
62@@ -159,11 +159,11 @@    
63         @rtype:  C{unicode}    
64         """    
65         if self.gender is None: return self.name    
66-        return self.name + u"." + self.gender    
67+        return self.name + "." + self.gender    
68     
69     
70 # Pattern to match annotation revision.    
71-re_annot = re.compile(u' *(\\d+):')    
72+re_annot = re.compile(' *(\\d+):')    
73 utf8_bom = codecs.BOM_UTF8.decode('utf-8')    
74     
75 def get_annotated(fname, revision):    
76@@ -186,12 +186,12 @@    
77     p = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.PIPE)    
78     out_data, err_data = p.communicate()    
79     if err_data != "":    
80-        msg= u'Warning: Mercurial command \"%s\" failed (message: "%s")' \    
81-            % (u" ".join(cmd), err_data)    
82+        msg= 'Warning: Mercurial command \"%s\" failed (message: "%s")' \    
83+            % (" ".join(cmd), err_data)    
84         raise LanguageReadError(msg)    
85     
86     out_data = out_data.decode('utf-8')    
87-    for idx, line in enumerate(out_data.split(u'\n')):    
88+    for idx, line in enumerate(out_data.split('\n')):    
89         if idx == 0 and line[0] == utf8_bom: line = line[1:]    
90         line = line.rstrip()    
91         m = re_annot.match(line)    
92@@ -201,7 +201,7 @@    
93             if idx == 0  and len(line) > i and line[i] == utf8_bom: i = i + 1    
94     
95             if len(line) == i:    
96-                yield int(m.group(1)), idx + 1, u''    
97+                yield int(m.group(1)), idx + 1, ''    
98             else:    
99                 yield int(m.group(1)), idx + 1, line[i:]    
100     
101@@ -227,9 +227,9 @@    
102     texts = []    
103     for rev, num, text in get_annotated(fname, revision):    
104         # cases!!    
105-        if len(text) == 0 or text[0] == u'#': continue    
106+        if len(text) == 0 or text[0] == '#': continue    
107     
108-        i, j = text.find(u' '), text.find(u'\t')    
109+        i, j = text.find(' '), text.find('\t')    
110         if i < 0:    
111             es = j    
112         elif j < 0:    
113@@ -238,24 +238,24 @@    
114             es = min([i, j])    
115     
116         if es < 0:    
117-            raise LanguageReadError(u"Invalid string-name at line %d in %r (text %r)"    
118+            raise LanguageReadError("Invalid string-name at line %d in %r (text %r)"    
119                     % (num, fname, text))    
120-        j = text.find(u'.')    
121+        j = text.find('.')    
122         if j > 0 and j < es:    
123             name, gender = text[:j], text[j + 1:es]    
124         else:    
125             name, gender = text[:es], None    
126     
127-        i = text.find(u':')    
128+        i = text.find(':')    
129         if i < 0:    
130-            raise LanguageReadError(u"Missing colon at line %d in %r (text %r)"    
131+            raise LanguageReadError("Missing colon at line %d in %r (text %r)"    
132                     % (num, fname, text))    
133     
134         text = text[i + 1:]    
135         tid = (name, gender)    
136     
137         if tid in line_numbers:    
138-            raise LanguageReadError(u"String %r is defined twice in %r (at lines %d and %d)"    
139+            raise LanguageReadError("String %r is defined twice in %r (at lines %d and %d)"    
140                     % (name, fname, line_numbers[name], num))    
141     
142         line_numbers[tid] = num    
143@@ -304,8 +304,8 @@    
144     
145     try:    
146         data = make_mapping(read_lang(master_name, revision))    
147-    except LanguageReadError, exc:    
148-        print "Warning: Retrieving version information failed: %r" % str(exc.err)    
149+    except LanguageReadError as exc:    
150+        print("Warning: Retrieving version information failed: %r" % str(exc.err))    
151         return None    
152     
153     cached_master_files[revision] = data    
154@@ -357,7 +357,7 @@    
155            This may reduce access to old master language revisions.    
156     """    
157     translation = make_mapping(translation) # Convert translation to a dict    
158-    t_names = set(translation.iterkeys()) # names in the translation that have not been processed.    
159+    t_names = set(translation.keys()) # names in the translation that have not been processed.    
160     
161     missing  = [] # Strings missing in the translation.    
162     outdated = [] # Strings that need to be updated.    
163diff -r d4bb7a333937 scripts/nml_langcheck/main.py    
164--- a/scripts/nml_langcheck/main.py    Fri Jan 30 13:10:17 2015 +0000    
165+++ b/scripts/nml_langcheck/main.py    Sat Jan 31 16:10:24 2015 +0000    
166@@ -30,7 +30,7 @@    
167  - Release of first version, cl 2.0    
168     
169 """    
170-import os, sys, getopt, ConfigParser    
171+import os, sys, getopt, configparser    
172 from nml_langcheck import output, languages    
173     
174 _version = '2.3'    
175@@ -120,7 +120,7 @@    
176                 usage(sys.stdout)    
177                 sys.exit(0)    
178             else:    
179-                print "Warning: Skipped the --help option."    
180+                print("Warning: Skipped the --help option.")    
181             return True    
182     
183         if opt in ('-e', '--ext'):    
184@@ -147,7 +147,7 @@    
185             if allow_cfg:    
186                 self.load_cfg(arg)    
187             else:    
188-                print "Warning: Skipped the --cfg option."    
189+                print("Warning: Skipped the --cfg option.")    
190             return True    
191     
192         return False    
193@@ -159,7 +159,7 @@    
194         @param fname: Name of the INI file.    
195         @type  fname: C{str}    
196         """    
197-        cfg_parser = ConfigParser.SafeConfigParser()    
198+        cfg_parser = configparser.SafeConfigParser()    
199         cfg_parser.read([fname])    
200         if not cfg_parser.has_section('options'): return    
201     
202@@ -169,7 +169,7 @@    
203             msg = "Unknown option '--%s' encountered in option file '%s'" \    
204                 % (opt, fname)    
205     
206-            print "Warning: " + msg    
207+            print("Warning: " + msg)    
208     
209     
210     def set_args(self, args):    
211@@ -254,8 +254,8 @@    
212     try:    
213         opts, args = getopt.getopt(sys.argv[1:],    
214                                    CmdLine.short_opts, CmdLine.long_opts)    
215-    except getopt.GetoptError, err:    
216-        print "nml_langcheck: " + str(err)    
217+    except getopt.GetoptError as err:    
218+        print("nml_langcheck: " + str(err))    
219         usage(sys.stdout)    
220         sys.exit(2)    
221     
222@@ -272,8 +272,8 @@    
223     
224     err = cmd_line.get_error()    
225     if err is not None:    
226-        print "nml_langcheck: " + err    
227-        print    
228+        print("nml_langcheck: " + err)    
229+        print()    
230         usage(sys.stdout)    
231         sys.exit(1)    
232     
233@@ -305,8 +305,8 @@    
234     """    
235     try:    
236         return languages.read_lang(fname, None)    
237-    except languages.LanguageReadError, exc:    
238-        print "Language file \"%s\" cannot be found: %r" % (fname, str(exc.err))    
239+    except languages.LanguageReadError as exc:    
240+        print("Language file \"%s\" cannot be found: %r" % (fname, str(exc.err)))    
241         return None    
242     
243     
244@@ -316,7 +316,7 @@    
245     
246     master_data = get_language(cmd_line.master)    
247     if master_data is None:    
248-        print "Quitting!"    
249+        print("Quitting!")    
250         sys.exit(1)    
251     
252     index_data = output.IndexData(cmd_line.transl_url, cmd_line.index_name, len(master_data))    
253@@ -324,11 +324,11 @@    
254     
255     for src, lang_name, dest in cmd_line.get_jobs():    
256         if cmd_line.verbose > 0:    
257-            print "%r -> %r" % (src, dest)    
258+            print("%r -> %r" % (src, dest))    
259     
260         translation = get_language(src)    
261         if translation is None:    
262-            print "Quitting!"    
263+            print("Quitting!")    
264             sys.exit(1)    
265     
266         missing, outdated, obsolete = languages.compare_langs(master_data, translation)    
267diff -r d4bb7a333937 src/render_docs.py    
268--- a/src/render_docs.py    Fri Jan 30 13:10:17 2015 +0000    
269+++ b/src/render_docs.py    Sat Jan 31 16:10:24 2015 +0000    
270@@ -6,7 +6,7 @@    
271   FIRS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    
272   See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with FIRS. If not, see <http://www.gnu.org/licenses/>.    
273 """    
274-print "[PYTHON] render docs"    
275+print("[PYTHON] render docs")    
276     
277 import codecs # used for writing files - more unicode friendly than standard open() module    
278     
279@@ -148,7 +148,7 @@    
280                  # convenient to have items sorted    
281                 result[industry_key]['economies'] = sorted(result[industry_key]['economies'], key=lambda economy: self.get_economy_name(economy))    
282         # return a list, sorted by economies (only need first economy entry in each list of economies)    
283-        return sorted(result.values(), key = lambda combo: self.get_economy_name(combo['economies'][0]))    
284+        return sorted(list(result.values()), key = lambda combo: self.get_economy_name(combo['economies'][0]))    
285     
286     
287     def industry_find_cargos_active_in_economy_for_industry(self, industry, economy, accept_or_produce):    
288@@ -177,7 +177,7 @@    
289                  # convenient to have items sorted    
290                 result[cargo_key]['economies'] = sorted(result[cargo_key]['economies'], key=lambda economy: self.get_economy_name(economy))    
291         # return a list, sorted by economies (only need first economy entry in each list of economies)    
292-        return sorted(result.values(), key = lambda combo: self.get_economy_name(combo['economies'][0]))    
293+        return sorted(list(result.values()), key = lambda combo: self.get_economy_name(combo['economies'][0]))    
294     
295     
296     def get_active_nav(self, doc_name, nav_link):    
297diff -r d4bb7a333937 src/render_pnml.py    
298--- a/src/render_pnml.py    Fri Jan 30 13:10:17 2015 +0000    
299+++ b/src/render_pnml.py    Sat Jan 31 16:10:24 2015 +0000    
300@@ -5,7 +5,7 @@    
301   See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with FIRS. If not, see <http://www.gnu.org/licenses/>.    
302 """    
303     
304-print "[PYTHON] render pnml"    
305+print("[PYTHON] render pnml")    
306     
307 import codecs # used for writing files - more unicode friendly than standard open() module    
308     
309@@ -82,7 +82,7 @@    
310         pool.join()    
311     
312     # linker    
313-    print "Linking"    
314+    print("Linking")    
315     template = header_item_templates['firs.pypnml']    
316     firs_pnml = codecs.open(os.path.join(firs.generated_files_path, 'firs.pnml'), 'w','utf8')    
317     firs_pnml.write(utils.unescape_chameleon_output(template(registered_industries=registered_industries, global_constants=global_constants,    
318diff -r d4bb7a333937 src/utils.py    
319--- a/src/utils.py    Fri Jan 30 13:10:17 2015 +0000    
320+++ b/src/utils.py    Sat Jan 31 16:10:24 2015 +0000    
321@@ -18,7 +18,7 @@    
322     
323     
324 def parse_base_lang():    
325-    print "[PARSE BASE LANG & EXTRA STRINGS] utils.py"    
326+    print("[PARSE BASE LANG & EXTRA STRINGS] utils.py")    
327     
328     import os.path    
329     currentdir = os.curdir    
330@@ -54,4 +54,4 @@    
331 def echo_message(message):    
332     # use to raise messages from templates to standard out (can't print directly from template render)    
333     # magically wraps these messages in ANSI colour to make them visible - they are only intended for noticeable messages, not general output    
334-    print '\033[33m' + message + '\033[0m'    
335+    print('\033[33m' + message + '\033[0m')