Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: prepare tools/icu/icutrim.py for Python 3 #24888

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions tools/icu/icutrim.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,25 @@
# Use "-h" to get help options.

from __future__ import print_function
import sys
import shutil
# for utf-8
reload(sys)
sys.setdefaultencoding("utf-8")

import json
import optparse
import os
import json
import re
import shutil
import sys

try:
# for utf-8 on Python 2
reload(sys)
sys.setdefaultencoding("utf-8")
except NameError:
pass # Python 3 already defaults to utf-8

try:
basestring # Python 2
except NameError:
basestring = str # Python 3

endian=sys.byteorder

Expand Down Expand Up @@ -214,7 +223,7 @@ def queueForRemoval(tree):
if(options.verbose>0):
print("* %s: %d items" % (tree, len(mytree["locs"])))
# do varible substitution for this tree here
if type(config["trees"][tree]) == str or type(config["trees"][tree]) == unicode:
if isinstance(config["trees"][tree], basestring):
treeStr = config["trees"][tree]
if(options.verbose>5):
print(" Substituting $%s for tree %s" % (treeStr, tree))
Expand Down