Skip to content

Commit 59f1b93

Browse files
committed
ENH: make use of set_readonly in the code
1 parent 975aeba commit 59f1b93

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

bin/heudiconv

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ def convert(items, symlink=True, converter=None,
997997
if exists(scaninfo):
998998
lgr.info("Post-treating %s file", scaninfo)
999999
treat_infofile(scaninfo)
1000-
os.chmod(outname, 0o0440)
1000+
set_readonly(outname)
10011001

10021002
if custom_callable is not None:
10031003
custom_callable(*item)
@@ -1168,9 +1168,9 @@ def tuneup_bids_json_files(json_files):
11681168
lgr.error("Failed to open magnitude file: %s", exc)
11691169

11701170
# might have been made R/O already
1171-
os.chmod(json_phasediffname, 0o0664)
1171+
set_readonly(json_phasediffname, False)
11721172
json.dump(json_, open(json_phasediffname, 'w'), indent=2)
1173-
os.chmod(json_phasediffname, 0o0444)
1173+
set_readonly(json_phasediffname)
11741174

11751175
# phasediff one should contain two PhaseDiff's
11761176
# -- one for original amplitude and the other already replicating what is there
@@ -1244,15 +1244,15 @@ in that one though
12441244
if global_options['overwrite'] and os.path.lexists(scaninfo):
12451245
# TODO: handle annexed file case
12461246
if not os.path.islink(scaninfo):
1247-
os.chmod(scaninfo, 0o0660)
1247+
set_readonly(scaninfo, False)
12481248
res = embedfunc.run()
1249-
os.chmod(scaninfo, 0o0444)
1249+
set_readonly(scaninfo)
12501250
if with_prov:
12511251
g = res.provenance.rdf()
12521252
g.parse(prov_file,
12531253
format='turtle')
12541254
g.serialize(prov_file, format='turtle')
1255-
os.chmod(prov_file, 0o0440)
1255+
set_readonly(prov_file)
12561256
except Exception as exc:
12571257
lgr.error("Embedding failed: %s", str(exc))
12581258
os.chdir(cwd)
@@ -1269,10 +1269,10 @@ def treat_infofile(filename):
12691269
j_slim = slim_down_info(j)
12701270
j_pretty = json_dumps_pretty(j_slim, indent=2, sort_keys=True)
12711271

1272-
os.chmod(filename, 0o0664)
1272+
set_readonly(filename, False)
12731273
with open(filename, 'wt') as fp:
12741274
fp.write(j_pretty)
1275-
os.chmod(filename, 0o0444)
1275+
set_readonly(filename)
12761276

12771277

12781278
def convert_dicoms(sid,

0 commit comments

Comments
 (0)