Skip to content

Commit 55b7d33

Browse files
committed
replaced str with basestring in instance checks to support unicode strings
1 parent 7afedad commit 55b7d33

File tree

16 files changed

+37
-37
lines changed

16 files changed

+37
-37
lines changed

doc/sphinxext/numpy_ext/docscrape_sphinx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def _str_references(self):
140140
out = []
141141
if self['References']:
142142
out += self._str_header('References')
143-
if isinstance(self['References'], str):
143+
if isinstance(self['References'], basestring):
144144
self['References'] = [self['References']]
145145
out.extend(self['References'])
146146
out += ['']

nipype/algorithms/modelgen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def _concatenate_info(self, infolist):
422422
for i, f in enumerate(self.inputs.functional_runs):
423423
if isinstance(f, list):
424424
numscans = len(f)
425-
elif isinstance(f, str):
425+
elif isinstance(f, basestring):
426426
img = load(f)
427427
numscans = img.get_shape()[3]
428428
else:

nipype/algorithms/rapidart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def _get_output_filenames(self, motionfile, output_dir):
279279
output_dir: string
280280
output directory in which the files will be generated
281281
"""
282-
if isinstance(motionfile, str):
282+
if isinstance(motionfile, basestring):
283283
infile = motionfile
284284
elif isinstance(motionfile, list):
285285
infile = motionfile[0]
@@ -350,7 +350,7 @@ def _detect_outliers_core(self, imgfile, motionfile, runidx, cwd=None):
350350
cwd = os.getcwd()
351351

352352
# read in functional image
353-
if isinstance(imgfile, str):
353+
if isinstance(imgfile, basestring):
354354
nim = load(imgfile)
355355
elif isinstance(imgfile, list):
356356
if len(imgfile) == 1:

nipype/interfaces/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ def _get_sorteddict(self, object, dictwithhash=False, hash_method=None,
541541
out = tuple(out)
542542
else:
543543
if isdefined(object):
544-
if (hash_files and isinstance(object, str) and
544+
if (hash_files and isinstance(object, basestring) and
545545
os.path.isfile(object)):
546546
if hash_method is None:
547547
hash_method = config.get('execution', 'hash_method')
@@ -984,7 +984,7 @@ def run(self, **inputs):
984984
else:
985985
inputs_str = ''
986986

987-
if len(e.args) == 1 and isinstance(e.args[0], str):
987+
if len(e.args) == 1 and isinstance(e.args[0], basestring):
988988
e.args = (e.args[0] + " ".join([message, inputs_str]),)
989989
else:
990990
e.args += (message, )

nipype/interfaces/dcmstack.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class DcmStack(NiftiGeneratorBase):
109109
output_spec = DcmStackOutputSpec
110110

111111
def _get_filelist(self, trait_input):
112-
if isinstance(trait_input, str):
112+
if isinstance(trait_input, basestring):
113113
if path.isdir(trait_input):
114114
return glob(path.join(trait_input, '*.dcm'))
115115
else:
@@ -334,7 +334,7 @@ def _run_interface(self, runtime):
334334
]
335335
if self.inputs.sort_order:
336336
sort_order = self.inputs.sort_order
337-
if isinstance(sort_order, str):
337+
if isinstance(sort_order, basestring):
338338
sort_order = [sort_order]
339339
nws.sort(key=make_key_func(sort_order))
340340
if self.inputs.merge_dim == traits.Undefined:

nipype/interfaces/io.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def _list_outputs(self):
520520
for argnum, arglist in enumerate(args):
521521
maxlen = 1
522522
for arg in arglist:
523-
if isinstance(arg, str) and hasattr(self.inputs, arg):
523+
if isinstance(arg, basestring) and hasattr(self.inputs, arg):
524524
arg = getattr(self.inputs, arg)
525525
if isinstance(arg, list):
526526
if (maxlen > 1) and (len(arg) != maxlen):
@@ -531,7 +531,7 @@ def _list_outputs(self):
531531
for i in range(maxlen):
532532
argtuple = []
533533
for arg in arglist:
534-
if isinstance(arg, str) and hasattr(self.inputs, arg):
534+
if isinstance(arg, basestring) and hasattr(self.inputs, arg):
535535
arg = getattr(self.inputs, arg)
536536
if isinstance(arg, list):
537537
argtuple.append(arg[i])
@@ -786,7 +786,7 @@ def _match_path(self, target_path):
786786

787787
def _run_interface(self, runtime):
788788
#Prepare some of the inputs
789-
if isinstance(self.inputs.root_paths, str):
789+
if isinstance(self.inputs.root_paths, basestring):
790790
self.inputs.root_paths = [self.inputs.root_paths]
791791
self.match_regex = re.compile(self.inputs.match_regex)
792792
if self.inputs.max_depth is Undefined:
@@ -1155,7 +1155,7 @@ def _list_outputs(self):
11551155
for argnum, arglist in enumerate(args):
11561156
maxlen = 1
11571157
for arg in arglist:
1158-
if isinstance(arg, str) and hasattr(self.inputs, arg):
1158+
if isinstance(arg, basestring) and hasattr(self.inputs, arg):
11591159
arg = getattr(self.inputs, arg)
11601160
if isinstance(arg, list):
11611161
if (maxlen > 1) and (len(arg) != maxlen):
@@ -1168,7 +1168,7 @@ def _list_outputs(self):
11681168
for i in range(maxlen):
11691169
argtuple = []
11701170
for arg in arglist:
1171-
if isinstance(arg, str) and \
1171+
if isinstance(arg, basestring) and \
11721172
hasattr(self.inputs, arg):
11731173
arg = getattr(self.inputs, arg)
11741174
if isinstance(arg, list):
@@ -1725,7 +1725,7 @@ def _list_outputs(self):
17251725
for argnum, arglist in enumerate(args):
17261726
maxlen = 1
17271727
for arg in arglist:
1728-
if isinstance(arg, str) and hasattr(self.inputs, arg):
1728+
if isinstance(arg, basestring) and hasattr(self.inputs, arg):
17291729
arg = getattr(self.inputs, arg)
17301730
if isinstance(arg, list):
17311731
if (maxlen > 1) and (len(arg) != maxlen):
@@ -1736,7 +1736,7 @@ def _list_outputs(self):
17361736
for i in range(maxlen):
17371737
argtuple = []
17381738
for arg in arglist:
1739-
if isinstance(arg, str) and hasattr(self.inputs, arg):
1739+
if isinstance(arg, basestring) and hasattr(self.inputs, arg):
17401740
arg = getattr(self.inputs, arg)
17411741
if isinstance(arg, list):
17421742
argtuple.append(arg[i])

nipype/interfaces/mne/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def _list_outputs(self):
8989
out_files = []
9090
for value in value_list:
9191
out_files.append(op.abspath(value))
92-
elif isinstance(value_list, str):
92+
elif isinstance(value_list, basestring):
9393
out_files = op.abspath(value_list)
9494
else:
9595
raise TypeError

nipype/interfaces/nipy/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def _run_interface(self, runtime):
8080
session_info = self.inputs.session_info
8181

8282
functional_runs = self.inputs.session_info[0]['scans']
83-
if isinstance(functional_runs, str):
83+
if isinstance(functional_runs, basestring):
8484
functional_runs = [functional_runs]
8585
nii = nb.load(functional_runs[0])
8686
data = nii.get_data()

nipype/interfaces/slicer/generate_classes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def add_class_to_package(class_codes, class_names, module_name, package_dir):
4747
def crawl_code_struct(code_struct, package_dir):
4848
subpackages = []
4949
for k, v in code_struct.iteritems():
50-
if isinstance(v, str) or isinstance(v, unicode):
50+
if isinstance(v, basestring) or isinstance(v, unicode):
5151
module_name = k.lower()
5252
class_name = k
5353
class_code = v
@@ -57,7 +57,7 @@ def crawl_code_struct(code_struct, package_dir):
5757
l1 = {}
5858
l2 = {}
5959
for key in v.keys():
60-
if (isinstance(v[key], str) or isinstance(v[key], unicode)):
60+
if (isinstance(v[key], basestring) or isinstance(v[key], unicode)):
6161
l1[key] = v[key]
6262
else:
6363
l2[key] = v[key]
@@ -313,7 +313,7 @@ def grab_xml(module, launcher):
313313
def parse_params(params):
314314
list = []
315315
for key, value in params.iteritems():
316-
if isinstance(value, str) or isinstance(value, unicode):
316+
if isinstance(value, basestring) or isinstance(value, unicode):
317317
list.append('%s="%s"' % (key, value.replace('"', "'")))
318318
else:
319319
list.append('%s=%s' % (key, value))

nipype/interfaces/spm/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ def _generate_job(self, prefix='', contents=None):
416416
if isinstance(val, np.ndarray):
417417
jobstring += self._generate_job(prefix=None,
418418
contents=val)
419-
elif isinstance(val, str):
419+
elif isinstance(val, basestring):
420420
jobstring += '\'%s\';...\n' % (val)
421421
else:
422422
jobstring += '%s;...\n' % str(val)
@@ -431,7 +431,7 @@ def _generate_job(self, prefix='', contents=None):
431431
jobstring += self._generate_job(newprefix,
432432
val[field])
433433
return jobstring
434-
if isinstance(contents, str):
434+
if isinstance(contents, basestring):
435435
jobstring += "%s = '%s';\n" % (prefix, contents)
436436
return jobstring
437437
jobstring += "%s = %s;\n" % (prefix, str(contents))

0 commit comments

Comments
 (0)