diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 091d4a6..ee27b10 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.2.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -13,6 +13,6 @@ repos: hooks: - id: isort - repo: https://github.com/PyCQA/flake8 - rev: 4.0.1 + rev: 7.1.1 hooks: - id: flake8 diff --git a/wsjtx.py b/wsjtx.py index 1010ac9..1ba23ca 100644 --- a/wsjtx.py +++ b/wsjtx.py @@ -594,16 +594,16 @@ def _encode(self): self._set_string(self._data['Mode']) self._set_string(self._data['ReportSent']) self._set_string(self._data['ReportReceived']) - self._set_string(self._data['TXPower']) - self._set_string(self._data['Comments']) - self._set_string(self._data['Name']) + self._set_string(self._data.get('TXPower')) + self._set_string(self._data.get('Comments')) + self._set_string(self._data.get('Name', '')) self._set_datetime(self._data['DateTimeOn']) - self._set_string(self._data['OpCall']) - self._set_string(self._data['MyCall']) - self._set_string(self._data['MyGrid']) - self._set_string(self._data['ExSent']) - self._set_string(self._data['ExReceived']) - self._set_string(self._data['PropMode']) + self._set_string(self._data.get('OpCall', '')) + self._set_string(self._data.get('MyCall', '')) + self._set_string(self._data.get('MyGrid', '')) + self._set_string(self._data.get('ExSent', '')) + self._set_string(self._data.get('ExReceived', '')) + self._set_string(self._data.get('PropMode', '')) @property def DateTimeOff(self): @@ -644,7 +644,11 @@ def Mode(self): @Mode.setter def Mode(self, val): - self._data['Mode'] = getattr(Mode, val).value + assert isinstance(val, str) + try: + self._data['Mode'] = getattr(Mode, val).value + except AttributeError: + self._data['Mode'] = val @property def ReportSent(self):