-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpaths.py
More file actions
31 lines (26 loc) · 1.09 KB
/
paths.py
File metadata and controls
31 lines (26 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
from dataclasses import dataclass
from qgis.core import QgsProject
@dataclass
class Paths:
"""
Stores and manages paths for the current QGIS project.
"""
source_project_dir_path: str
source_project_dir_name: str
source_project_file_name: str
source_project_zip_file_path: str
@staticmethod
def get_paths() -> 'Paths':
"""
Creates and returns a `Paths` object with the relevant project paths.
Returns:
Paths: An object containing the project directory path, directory name,
project file name, and the path to the ZIP archive of the project.
"""
source_project_dir_path = QgsProject.instance().absolutePath()
source_project_dir_name = os.path.basename(source_project_dir_path)
source_project_file_name = os.path.basename(QgsProject.instance().fileName())
source_project_zip_file_path = source_project_dir_path + '.zip'
return Paths(source_project_dir_path, source_project_dir_name, source_project_file_name,
source_project_zip_file_path)