Skip to content

Commit 4eb6599

Browse files
committed
fix: use NameError to capture lack of rdflib when writing rdf
1 parent 9846d30 commit 4eb6599

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

nipype/interfaces/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,15 +1192,15 @@ def write_provenance(self, results, filename='provenance', format='turtle'):
11921192
try:
11931193
if format in ['turtle', 'all']:
11941194
g.rdf().serialize(filename + '.ttl', format='turtle')
1195-
except ImportError:
1195+
except (ImportError, NameError):
11961196
format = 'all'
11971197
finally:
11981198
if format in ['provn', 'all']:
11991199
with open(filename + '.provn', 'wt') as fp:
12001200
fp.writelines(g.get_provn())
12011201
if format in ['json', 'all']:
12021202
with open(filename + '.json', 'wt') as fp:
1203-
prov.json.dump(g, fp, cls= prov.ProvBundle.JSONEncoder)
1203+
pm.json.dump(g, fp, cls=pm.ProvBundle.JSONEncoder)
12041204
return g
12051205

12061206

nipype/pipeline/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,14 +938,14 @@ def write_prov(graph, filename=None, format='turtle'):
938938
try:
939939
if format in ['turtle', 'all']:
940940
g.rdf().serialize(filename + '.ttl', format='turtle')
941-
except ImportError:
941+
except (ImportError, NameError):
942942
format = 'all'
943943
finally:
944944
if format in ['provn', 'all']:
945945
with open(filename + '.provn', 'wt') as fp:
946946
fp.writelines(g.get_provn())
947947
if format in ['json', 'all']:
948948
with open(filename + '.json', 'wt') as fp:
949-
prov.json.dump(g, fp, cls= prov.ProvBundle.JSONEncoder)
949+
prov.json.dump(g, fp, cls=prov.ProvBundle.JSONEncoder)
950950
return g
951951

0 commit comments

Comments
 (0)