Skip to content

Commit 311d94d

Browse files
GutsDucarouge
authored andcommitted
Add class method to create QdtProfile from folder
1 parent dbfd1c3 commit 311d94d

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

qgis_deployment_toolbelt/profiles/qdt_profile.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,39 @@ def from_json(
188188
**profile_data,
189189
)
190190

191+
@classmethod
192+
def from_profile_folder(cls, input_profile_folder: Path) -> Self:
193+
"""Create object from a QGIS profile folder. Must contain a QGIS/QGIS3.ini file.
194+
195+
Args:
196+
input_profile_folder (Path): path to the folder containgin a QGIS plugin
197+
198+
Returns:
199+
Self: instanciated object
200+
"""
201+
# check that input path is a folder
202+
check_path(
203+
input_path=input_profile_folder,
204+
must_exists=True,
205+
must_be_a_folder=True,
206+
must_be_a_file=False,
207+
must_be_readable=True,
208+
)
209+
# check if the folder contains a QGIS3.ini file
210+
profile_qgis_ini = input_profile_folder / "QGIS/QGIS3.ini"
211+
check_path(
212+
input_path=profile_qgis_ini,
213+
must_be_a_file=True,
214+
must_be_readable=True,
215+
must_exists=True,
216+
)
217+
218+
# return new instance with loaded object
219+
return cls(
220+
folder=input_profile_folder.name,
221+
loaded_from_json=False,
222+
)
223+
191224
@property
192225
def alias(self) -> str:
193226
"""Returns the profile's alias.

0 commit comments

Comments
 (0)