Skip to content

Commit 3287fed

Browse files
committed
0.0.3 release
2 parents d67d46d + 96d3d2e commit 3287fed

17 files changed

+882
-190
lines changed

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changes
22

3+
## 0.0.3 (2019-09-08)
4+
5+
* Implemented #1: Workbenches can be renamed.
6+
* Implemented #2: Workbenches can be imported and exported.
7+
* Implemented #8: Warnings because of unnamed UI elements are turned off by default. If required, they can be activated in the configuration.
8+
39
## 0.0.2 (2019-09-03)
410

511
* Fixed #6: `workbench` does not crash anymore when certain other plugins are loaded. Background: Their UI exposes its Qt parent as a property instead of a method.

i18n/qgist_de.qm

593 Bytes
Binary file not shown.

i18n/qgist_de.ts

Lines changed: 213 additions & 87 deletions
Large diffs are not rendered by default.

i18n/qgist_en.ts

Lines changed: 213 additions & 87 deletions
Large diffs are not rendered by default.

icons/Export.svg

Lines changed: 76 additions & 0 deletions
Loading

icons/Import.svg

Lines changed: 76 additions & 0 deletions
Loading

icons/Rename.svg

Lines changed: 73 additions & 0 deletions
Loading

metadata.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
name=QGIST Workbench
2323
description=Organizing Toolbars
2424
about=QGIST Workbench is a QGIS plugin for organizing toolbars and dockwidgets.
25-
version=0.0.2
25+
version=0.0.3
2626
qgisMinimumVersion=3.0
2727
author=QGIST project
2828
email=info@qgist.org

qgist/config.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
QGIST_CONFIG_FLD,
5050
)
5151
from .error import (
52+
QgistConfigFormatError,
5253
QgistConfigKeyError,
5354
QgistTypeError,
5455
QgistValueError,
@@ -107,7 +108,11 @@ def __init__(self, fn):
107108
if not os.path.isfile(fn):
108109
raise QgistValueError(translate('global', '"fn" must be a file. (config)'))
109110
with open(fn, 'r', encoding = 'utf-8') as f:
110-
self._data = json.loads(f.read())
111+
data = f.read()
112+
try:
113+
self._data = json.loads(data)
114+
except:
115+
raise QgistConfigFormatError(translate('global', 'Config does not contain valid JSON. (config)'))
111116
if not isinstance(self._data, dict):
112117
raise QgistTypeError(translate('global', 'Configuration data must be a dict. (config)'))
113118

@@ -179,3 +184,38 @@ def _save(self):
179184

180185
if backup_fn is not None:
181186
os.unlink(backup_fn)
187+
188+
@staticmethod
189+
def import_config(fn):
190+
191+
if not isinstance(fn, str):
192+
raise QgistTypeError(translate('global', '"fn" must be str. (config import)'))
193+
if not os.path.exists(fn):
194+
raise QgistValueError(translate('global', '"fn" must exists. (config import)'))
195+
if not os.path.isfile(fn):
196+
raise QgistValueError(translate('global', '"fn" must be a file. (config import)'))
197+
198+
with open(fn, 'r', encoding = 'utf-8') as f:
199+
raw = f.read()
200+
201+
try:
202+
value = json.loads(raw)
203+
except:
204+
raise QgistConfigFormatError(translate('global', '"fn" does not contain valid JSON. (config import)'))
205+
206+
return value
207+
208+
@staticmethod
209+
def export_config(fn, value):
210+
211+
if not isinstance(fn, str):
212+
raise QgistTypeError(translate('global', '"fn" must be str. (config export)'))
213+
if not os.path.exists(os.path.dirname(fn)):
214+
raise QgistValueError(translate('global', 'Parent of "fn" must exists. (config export)'))
215+
if not os.path.isdir(os.path.dirname(fn)):
216+
raise QgistValueError(translate('global', 'Parent of "fn" must be a directory. (config export)'))
217+
if not config_class._check_value(value):
218+
raise QgistTypeError(translate('global', '"value" contains not allowed types. (config export)'))
219+
220+
with open(fn, 'w', encoding = 'utf-8') as f:
221+
f.write(json.dumps(value, indent = 4, sort_keys = True))

qgist/error.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
class QgistAttributeError(AttributeError):
3232
pass
3333

34+
class QgistConfigFormatError(KeyError):
35+
pass
36+
3437
class QgistConfigKeyError(KeyError):
3538
pass
3639

0 commit comments

Comments
 (0)