File tree 1 file changed +16
-7
lines changed
1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change 12
12
# Use "-h" to get help options.
13
13
14
14
from __future__ import print_function
15
- import sys
16
- import shutil
17
- # for utf-8
18
- reload (sys )
19
- sys .setdefaultencoding ("utf-8" )
20
15
16
+ import json
21
17
import optparse
22
18
import os
23
- import json
24
19
import re
20
+ import shutil
21
+ import sys
22
+
23
+ try :
24
+ # for utf-8 on Python 2
25
+ reload (sys )
26
+ sys .setdefaultencoding ("utf-8" )
27
+ except NameError :
28
+ pass # Python 3 already defaults to utf-8
29
+
30
+ try :
31
+ basestring # Python 2
32
+ except NameError :
33
+ basestring = str # Python 3
25
34
26
35
endian = sys .byteorder
27
36
@@ -214,7 +223,7 @@ def queueForRemoval(tree):
214
223
if (options .verbose > 0 ):
215
224
print ("* %s: %d items" % (tree , len (mytree ["locs" ])))
216
225
# do varible substitution for this tree here
217
- if type (config ["trees" ][tree ]) == str or type ( config [ "trees" ][ tree ]) == unicode :
226
+ if isinstance (config ["trees" ][tree ], basestring ) :
218
227
treeStr = config ["trees" ][tree ]
219
228
if (options .verbose > 5 ):
220
229
print (" Substituting $%s for tree %s" % (treeStr , tree ))
You can’t perform that action at this time.
0 commit comments