GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tools: fixup icutrim.py use of string and bytes objects · nodejs/node@baf56f8

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • tools/icu
    • icutrim.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎tools/icu/icutrim.py‎

Copy file name to clipboardExpand all lines: tools/icu/icutrim.py
+8-9Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from __future__ import print_function
1515

16+
import io
1617
import json
1718
import optparse
1819
import os
@@ -159,9 +160,8 @@ def runcmd(tool, cmd, doContinue=False):
159160
return rc
160161

161162
## STEP 0 - read in json config
162-
fi= open(options.filterfile, "rb")
163-
config=json.load(fi)
164-
fi.close()
163+
with io.open(options.filterfile, encoding='utf-8') as fi:
164+
config = json.load(fi)
165165

166166
if options.locales:
167167
config["variables"] = config.get("variables", {})
@@ -285,10 +285,9 @@ def addTreeByType(tree, mytree):
285285
# read in the resource list for the tree
286286
treelistfile = os.path.join(options.tmpdir,"%s.lst" % tree)
287287
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() for i in range(len(treeitems))]
291-
fi.close()
288+
with io.open(treelistfile, 'r', encoding='utf-8') as fi:
289+
treeitems = fi.readlines()
290+
trees[tree]["locs"] = [line.strip() for line in treeitems]
292291
if tree not in config.get("trees", {}):
293292
print(" Warning: filter file %s does not mention trees.%s - will be kept as-is" % (options.filterfile, tree))
294293
else:
@@ -317,12 +316,12 @@ def removeList(count=0):
317316
erritems = fi.readlines()
318317
fi.close()
319318
#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'))
321320
for i in range(len(erritems)):
322321
line = erritems[i].strip()
323322
m = pat.match(line)
324323
if m:
325-
toDelete = m.group(1)
324+
toDelete = m.group(1).decode("utf-8")
326325
if(options.verbose > 5):
327326
print("<< %s added to delete" % toDelete)
328327
remove.add(toDelete)

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.