Skip to content

Commit

Permalink
0.0.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
s-m-e committed Sep 9, 2019
2 parents 60330fc + d1e50ab commit 8af2497
Show file tree
Hide file tree
Showing 17 changed files with 1,166 additions and 181 deletions.
9 changes: 9 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changes

## 0.0.2 (2019-09-09)

* Implemented #1: Toolbars can be renamed.
* Implemented #2: Toolbars can be imported and exported.
* Implemented #6: Toolbars can contain separators.
* Fixed #4: Toolbars are properly removed, not only emptied.
* Synced QGIST base library, added improvements from QGIST Workbench
* Added missing data type checks in internal APIs

## 0.0.1 (2019-09-01)

* Initial release.
Binary file modified i18n/qgist_de.qm
Binary file not shown.
360 changes: 278 additions & 82 deletions i18n/qgist_de.ts

Large diffs are not rendered by default.

360 changes: 278 additions & 82 deletions i18n/qgist_en.ts

Large diffs are not rendered by default.

76 changes: 76 additions & 0 deletions icons/Export.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 76 additions & 0 deletions icons/Import.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions icons/Rename.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions icons/SeparatorAdd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
name=QGIST Toolbar Generator
description=Generating Toolbars
about=QGIST Toolbar Generator is a QGIS plugin for generating toolbars.
version=0.0.1
version=0.0.2
qgisMinimumVersion=3.0
author=QGIST project
email=info@qgist.org
Expand Down
42 changes: 41 additions & 1 deletion qgist/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
QGIST_CONFIG_FLD,
)
from .error import (
QgistConfigFormatError,
QgistConfigKeyError,
QgistTypeError,
QgistValueError,
Expand Down Expand Up @@ -107,7 +108,11 @@ def __init__(self, fn):
if not os.path.isfile(fn):
raise QgistValueError(translate('global', '"fn" must be a file. (config)'))
with open(fn, 'r', encoding = 'utf-8') as f:
self._data = json.loads(f.read())
data = f.read()
try:
self._data = json.loads(data)
except:
raise QgistConfigFormatError(translate('global', 'Config does not contain valid JSON. (config)'))
if not isinstance(self._data, dict):
raise QgistTypeError(translate('global', 'Configuration data must be a dict. (config)'))

Expand Down Expand Up @@ -179,3 +184,38 @@ def _save(self):

if backup_fn is not None:
os.unlink(backup_fn)

@staticmethod
def import_config(fn):

if not isinstance(fn, str):
raise QgistTypeError(translate('global', '"fn" must be str. (config import)'))
if not os.path.exists(fn):
raise QgistValueError(translate('global', '"fn" must exists. (config import)'))
if not os.path.isfile(fn):
raise QgistValueError(translate('global', '"fn" must be a file. (config import)'))

with open(fn, 'r', encoding = 'utf-8') as f:
raw = f.read()

try:
value = json.loads(raw)
except:
raise QgistConfigFormatError(translate('global', '"fn" does not contain valid JSON. (config import)'))

return value

@staticmethod
def export_config(fn, value):

if not isinstance(fn, str):
raise QgistTypeError(translate('global', '"fn" must be str. (config export)'))
if not os.path.exists(os.path.dirname(fn)):
raise QgistValueError(translate('global', 'Parent of "fn" must exists. (config export)'))
if not os.path.isdir(os.path.dirname(fn)):
raise QgistValueError(translate('global', 'Parent of "fn" must be a directory. (config export)'))
if not config_class._check_value(value):
raise QgistTypeError(translate('global', '"value" contains not allowed types. (config export)'))

with open(fn, 'w', encoding = 'utf-8') as f:
f.write(json.dumps(value, indent = 4, sort_keys = True))
Loading

0 comments on commit 8af2497

Please sign in to comment.