[S] Change in pysim[master]: Fix run-editor bug with cmd2 >= 2.0.0 compatibility
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/33420 ) Change subject: Fix run-editor bug with cmd2 >= 2.0.0 compatibility ...................................................................... Fix run-editor bug with cmd2 >= 2.0.0 compatibility In cmd2, the upstream authors decided to rename a method in 2.0.0 without providing a backwards compatibility wrapper. Let's add that locally. Change-Id: Iaa17b93db13ba330551799cce5f0388c78217224 Closes: OS#6071 --- M pySim-shell.py M pySim/filesystem.py 2 files changed, 27 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/20/33420/1 diff --git a/pySim-shell.py b/pySim-shell.py index f6cd75d..b018102 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from typing import List +from typing import List, Optional import json import traceback @@ -144,7 +144,16 @@ return rs, card -class PysimApp(cmd2.Cmd): +class Cmd2Compat(cmd2.Cmd): + """Backwards-compatibility wrapper around cmd2.Cmd to support older and newer + releases. See https://github.com/python-cmd2/cmd2/blob/master/CHANGELOG.md""" + def run_editor(self, file_path: Optional[str] = None) -> None: + if version.parse(cmd2.__version__) < version.parse("2.0.0"): + return self._run_editor(file_path) + else: + return super().run_editor(file_path) + +class PysimApp(Cmd2Compat): CUSTOM_CATEGORY = 'pySim Commands' def __init__(self, card, rs, sl, ch, script=None): diff --git a/pySim/filesystem.py b/pySim/filesystem.py index b5d0ccd..04e849b 100644 --- a/pySim/filesystem.py +++ b/pySim/filesystem.py @@ -649,7 +649,7 @@ with open(filename, 'w') as text_file: json.dump(orig_json, text_file, indent=4) # run a text editor - self._cmd._run_editor(filename) + self._cmd.run_editor(filename) with open(filename, 'r') as text_file: edited_json = json.load(text_file) if edited_json == orig_json: @@ -917,7 +917,7 @@ with open(filename, 'w') as text_file: json.dump(orig_json, text_file, indent=4) # run a text editor - self._cmd._run_editor(filename) + self._cmd.run_editor(filename) with open(filename, 'r') as text_file: edited_json = json.load(text_file) if edited_json == orig_json: -- To view, visit https://gerrit.osmocom.org/c/pysim/+/33420 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Iaa17b93db13ba330551799cce5f0388c78217224 Gerrit-Change-Number: 33420 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge@osmocom.org> Gerrit-MessageType: newchange
participants (1)
-
laforge