Skip to content

Commit b17b7ac

Browse files
committed
Add class method to create QdtProfile from folder
1 parent d27ba93 commit b17b7ac

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
@@ -181,6 +181,39 @@ def from_json(cls, profile_json_path: Path, profile_folder: Path = None) -> Self
181181
**profile_data,
182182
)
183183

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

0 commit comments

Comments
 (0)