diff options
author | cclauss <cclauss@bluewin.ch> | 2018-12-07 09:55:32 +0100 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-12-10 08:37:54 -0800 |
commit | a91293d4d9ab403046ab5eb022332e4e3d249bd3 (patch) | |
tree | e0a972939e2a98857fb262bdec112b8a44a848b9 /tools | |
parent | 1f85ea979ccef3c52ec4ca3263306e527b625498 (diff) | |
download | android-node-v8-a91293d4d9ab403046ab5eb022332e4e3d249bd3.tar.gz android-node-v8-a91293d4d9ab403046ab5eb022332e4e3d249bd3.tar.bz2 android-node-v8-a91293d4d9ab403046ab5eb022332e4e3d249bd3.zip |
tools: prepare tools/icu/icutrim.py for Python 3
PR-URL: https://github.com/nodejs/node/pull/24888
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/icu/icutrim.py | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/tools/icu/icutrim.py b/tools/icu/icutrim.py index 2b771cb641..116af32e02 100755 --- a/tools/icu/icutrim.py +++ b/tools/icu/icutrim.py @@ -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 @@ -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)) |