forked from public/pysim
[pylint] Fix referencing undefined variable 'shutil'
Let's just use the scope limited TemporaryDirectory() instead, so the temporary directory will be removed by Python automatically. pySim/filesystem.py:679:16: E0602: Undefined variable 'shutil' (undefined-variable) Change-Id: I4ea833fd79f4342c33899124379be509ba1e35ed
This commit is contained in:
@@ -659,8 +659,7 @@ class LinFixedEF(CardEF):
|
|||||||
def do_edit_record_decoded(self, opts):
|
def do_edit_record_decoded(self, opts):
|
||||||
"""Edit the JSON representation of one record in an editor."""
|
"""Edit the JSON representation of one record in an editor."""
|
||||||
(orig_json, sw) = self._cmd.rs.read_record_dec(opts.record_nr)
|
(orig_json, sw) = self._cmd.rs.read_record_dec(opts.record_nr)
|
||||||
dirname = tempfile.mkdtemp(prefix='pysim_')
|
with tempfile.TemporaryDirectory(prefix='pysim_') as dirname:
|
||||||
try:
|
|
||||||
filename = '%s/file' % dirname
|
filename = '%s/file' % dirname
|
||||||
# write existing data as JSON to file
|
# write existing data as JSON to file
|
||||||
with open(filename, 'w') as text_file:
|
with open(filename, 'w') as text_file:
|
||||||
@@ -675,8 +674,6 @@ class LinFixedEF(CardEF):
|
|||||||
(data, sw) = self._cmd.rs.update_record_dec(opts.record_nr, edited_json)
|
(data, sw) = self._cmd.rs.update_record_dec(opts.record_nr, edited_json)
|
||||||
if data:
|
if data:
|
||||||
self._cmd.poutput_json(data)
|
self._cmd.poutput_json(data)
|
||||||
finally:
|
|
||||||
shutil.rmtree(dirname)
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, fid:str, sfid:str=None, name:str=None, desc:str=None,
|
def __init__(self, fid:str, sfid:str=None, name:str=None, desc:str=None,
|
||||||
|
|||||||
Reference in New Issue
Block a user