|
13 | 13 |
|
14 | 14 | from __future__ importprint_function |
15 | 15 |
|
| 16 | +importio |
16 | 17 | importjson |
17 | 18 | importoptparse |
18 | 19 | importos |
@@ -159,9 +160,8 @@ def runcmd(tool, cmd, doContinue=False): |
159 | 160 | returnrc |
160 | 161 |
|
161 | 162 | ## STEP 0 - read in json config |
162 | | -fi=open(options.filterfile, "rb") |
163 | | -config=json.load(fi) |
164 | | -fi.close() |
| 163 | +withio.open(options.filterfile, encoding='utf-8') asfi: |
| 164 | +config=json.load(fi) |
165 | 165 |
|
166 | 166 | ifoptions.locales: |
167 | 167 | config["variables"] =config.get("variables", {}) |
@@ -285,10 +285,9 @@ def addTreeByType(tree, mytree): |
285 | 285 | # read in the resource list for the tree |
286 | 286 | treelistfile=os.path.join(options.tmpdir,"%s.lst"%tree) |
287 | 287 | runcmd("iculslocs", "-i %s -N %s -T %s -l > %s"% (outfile, dataname, tree, treelistfile)) |
288 | | -fi=open(treelistfile, 'rb') |
289 | | -treeitems=fi.readlines() |
290 | | -trees[tree]["locs"] = [treeitems[i].strip() foriinrange(len(treeitems))] |
291 | | -fi.close() |
| 288 | +withio.open(treelistfile, 'r', encoding='utf-8') asfi: |
| 289 | +treeitems=fi.readlines() |
| 290 | +trees[tree]["locs"] = [line.strip() forlineintreeitems] |
292 | 291 | iftreenotinconfig.get("trees", {}): |
293 | 292 | print(" Warning: filter file %s does not mention trees.%s - will be kept as-is"% (options.filterfile, tree)) |
294 | 293 | else: |
@@ -317,12 +316,12 @@ def removeList(count=0): |
317 | 316 | erritems=fi.readlines() |
318 | 317 | fi.close() |
319 | 318 | #Item zone/zh_Hant_TW.res depends on missing item zone/zh_Hant.res |
320 | | -pat=re.compile("""^Item ([^ ]+) depends on missing item ([^ ]+).*""") |
| 319 | +pat=re.compile(bytes(r"^Item ([^ ]+) depends on missing item ([^ ]+).*", 'utf-8')) |
321 | 320 | foriinrange(len(erritems)): |
322 | 321 | line=erritems[i].strip() |
323 | 322 | m=pat.match(line) |
324 | 323 | ifm: |
325 | | -toDelete=m.group(1) |
| 324 | +toDelete=m.group(1).decode("utf-8") |
326 | 325 | if(options.verbose>5): |
327 | 326 | print("<< %s added to delete"%toDelete) |
328 | 327 | remove.add(toDelete) |
|
0 commit comments