@@ -64,19 +64,19 @@ def get_config_path():
6464
6565 root_fld = QgsApplication .qgisSettingsDirPath ()
6666 if os .path .exists (root_fld ) and not os .path .isdir (root_fld ):
67- raise QgistValueError (translate ('global' , 'qgis settings path does not point to a directory' ))
67+ raise QgistValueError (translate ('global' , 'QGIS settings path does not point to a directory. (config path) ' ))
6868 if not os .path .exists (root_fld ):
69- raise QgistValueError (translate ('global' , 'qgis settings path does not exist' )) # TODO create?
69+ raise QgistValueError (translate ('global' , 'QGIS settings path does not exist. (config path) ' )) # TODO create?
7070
7171 root_qgis_fld = os .path .join (root_fld , QGIS_CONFIG_FLD )
7272 if os .path .exists (root_qgis_fld ) and not os .path .isdir (root_qgis_fld ):
73- raise QgistValueError (translate ('global' , 'qgis plugin configuration path exists but is not a directory' ))
73+ raise QgistValueError (translate ('global' , 'QGIS plugin configuration path exists but is not a directory. (config path) ' ))
7474 if not os .path .exists (root_qgis_fld ):
7575 os .mkdir (root_qgis_fld )
7676
7777 root_qgis_qgist_fld = os .path .join (root_qgis_fld , QGIST_CONFIG_FLD )
7878 if os .path .exists (root_qgis_qgist_fld ) and not os .path .isdir (root_qgis_qgist_fld ):
79- raise QgistValueError (translate ('global' , 'qgist configuration path exists but is not a directory' ))
79+ raise QgistValueError (translate ('global' , 'QGIST configuration path exists but is not a directory. (config path) ' ))
8080 if not os .path .exists (root_qgis_qgist_fld ):
8181 os .mkdir (root_qgis_qgist_fld )
8282
@@ -92,40 +92,40 @@ class config_class:
9292 def __init__ (self , fn ):
9393
9494 if not isinstance (fn , str ):
95- raise QgistTypeError (translate ('global' , 'fn must be str' ))
95+ raise QgistTypeError (translate ('global' , '"fn" must be str. (config) ' ))
9696
9797 self ._fn = fn
9898
9999 if not os .path .exists (fn ):
100100 if not os .path .exists (os .path .dirname (fn )):
101- raise QgistValueError (translate ('global' , 'parent of fn must exists' ))
101+ raise QgistValueError (translate ('global' , 'Parent of "fn" must exists. (config) ' ))
102102 if not os .path .isdir (os .path .dirname (fn )):
103- raise QgistValueError (translate ('global' , 'parent of fn must be a directory' ))
103+ raise QgistValueError (translate ('global' , 'Parent of "fn" must be a directory. (config) ' ))
104104 self ._data = {}
105105 self ._save ()
106106 else :
107107 if not os .path .isfile (fn ):
108- raise QgistValueError (translate ('global' , 'fn must be a file' ))
108+ raise QgistValueError (translate ('global' , '"fn" must be a file. (config) ' ))
109109 with open (fn , 'r' , encoding = 'utf-8' ) as f :
110110 self ._data = json .loads (f .read ())
111111 if not isinstance (self ._data , dict ):
112- raise QgistTypeError (translate ('global' , 'configuration data must be a dict' ))
112+ raise QgistTypeError (translate ('global' , 'Configuration data must be a dict. (config) ' ))
113113
114114 def __getitem__ (self , name ):
115115
116116 if not isinstance (name , str ):
117- raise QgistTypeError (translate ('global' , 'name must be str' ))
117+ raise QgistTypeError (translate ('global' , '" name" must be str. (config getitem) ' ))
118118 if name not in self ._data .keys ():
119- raise QgistConfigKeyError (translate ('global' , 'unknown configuration field name' ))
119+ raise QgistConfigKeyError (translate ('global' , 'Unknown configuration field " name". (config getitem) ' ))
120120
121121 return copy .deepcopy (self ._data [name ])
122122
123123 def __setitem__ (self , name , value ):
124124
125125 if not isinstance (name , str ):
126- raise QgistTypeError (translate ('global' , 'name must be str' ))
126+ raise QgistTypeError (translate ('global' , '" name" must be str. (config setitem) ' ))
127127 if not config_class ._check_value (value ):
128- raise QgistTypeError (translate ('global' , 'value contains not allowed types' ))
128+ raise QgistTypeError (translate ('global' , '" value" contains not allowed types. (config setitem) ' ))
129129
130130 self ._data [name ] = value
131131 self ._save ()
@@ -171,7 +171,7 @@ def _save(self):
171171 break
172172 attempt += 1
173173 if not attempt_ok :
174- raise QgistValueError (translate ('global' , 'could not backup old configuration before saving new - too many old backups' ))
174+ raise QgistValueError (translate ('global' , 'Could not backup old configuration before saving new - too many old backups. (config save) ' ))
175175 os .rename (self ._fn , backup_fn )
176176
177177 with open (self ._fn , 'w' , encoding = 'utf-8' ) as f :
0 commit comments