Skip to content

Commit 8af2497

Browse files
committed
0.0.2 release
2 parents 60330fc + d1e50ab commit 8af2497

File tree

17 files changed

+1166
-181
lines changed

17 files changed

+1166
-181
lines changed

CHANGES.md

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

3+
## 0.0.2 (2019-09-09)
4+
5+
* Implemented #1: Toolbars can be renamed.
6+
* Implemented #2: Toolbars can be imported and exported.
7+
* Implemented #6: Toolbars can contain separators.
8+
* Fixed #4: Toolbars are properly removed, not only emptied.
9+
* Synced QGIST base library, added improvements from QGIST Workbench
10+
* Added missing data type checks in internal APIs
11+
312
## 0.0.1 (2019-09-01)
413

514
* Initial release.

i18n/qgist_de.qm

668 Bytes
Binary file not shown.

i18n/qgist_de.ts

Lines changed: 278 additions & 82 deletions
Large diffs are not rendered by default.

i18n/qgist_en.ts

Lines changed: 278 additions & 82 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

icons/SeparatorAdd.svg

Lines changed: 75 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 Toolbar Generator
2323
description=Generating Toolbars
2424
about=QGIST Toolbar Generator is a QGIS plugin for generating toolbars.
25-
version=0.0.1
25+
version=0.0.2
2626
qgisMinimumVersion=3.0
2727
author=QGIST project
2828

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))

0 commit comments

Comments
 (0)