Change in pysim[master]: [pylint] Fix referencing undefined variable 'shutil'

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

fixeria gerrit-no-reply at lists.osmocom.org
Sun May 2 00:56:52 UTC 2021


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/24032 )


Change subject: [pylint] Fix referencing undefined variable 'shutil'
......................................................................

[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
---
M pySim/filesystem.py
1 file changed, 1 insertion(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/32/24032/1

diff --git a/pySim/filesystem.py b/pySim/filesystem.py
index dec521e..edfe85d 100644
--- a/pySim/filesystem.py
+++ b/pySim/filesystem.py
@@ -659,8 +659,7 @@
         def do_edit_record_decoded(self, opts):
             """Edit the JSON representation of one record in an editor."""
             (orig_json, sw) = self._cmd.rs.read_record_dec(opts.record_nr)
-            dirname = tempfile.mkdtemp(prefix='pysim_')
-            try:
+            with tempfile.TemporaryDirectory(prefix='pysim_') as dirname:
                 filename = '%s/file' % dirname
                 # write existing data as JSON to file
                 with open(filename, 'w') as text_file:
@@ -675,8 +674,6 @@
                     (data, sw) = self._cmd.rs.update_record_dec(opts.record_nr, edited_json)
                     if data:
                         self._cmd.poutput_json(data)
-            finally:
-                shutil.rmtree(dirname)
 
 
     def __init__(self, fid:str, sfid:str=None, name:str=None, desc:str=None,

-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/24032
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I4ea833fd79f4342c33899124379be509ba1e35ed
Gerrit-Change-Number: 24032
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210502/11488c94/attachment.htm>


More information about the gerrit-log mailing list