mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 10:24:38 +08:00
Use context manager for writing param_file
This commit is contained in:
@@ -584,14 +584,13 @@ class ToolEvaluator(object):
|
||||
if self.tool.profile < 16.04 and command and "$param_file" in command:
|
||||
fd, param_filename = tempfile.mkstemp(dir=directory)
|
||||
os.close(fd)
|
||||
f = open(param_filename, "w")
|
||||
for key, value in param_dict.items():
|
||||
# parameters can be strings or lists of strings, coerce to list
|
||||
if not isinstance(value, list):
|
||||
value = [value]
|
||||
for elem in value:
|
||||
f.write('%s=%s\n' % (key, elem))
|
||||
f.close()
|
||||
with open(param_filename, "w") as f:
|
||||
for key, value in param_dict.items():
|
||||
# parameters can be strings or lists of strings, coerce to list
|
||||
if not isinstance(value, list):
|
||||
value = [value]
|
||||
for elem in value:
|
||||
f.write('%s=%s\n' % (key, elem))
|
||||
self.__register_extra_file('param_file', param_filename)
|
||||
return param_filename
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user