File tree 2 files changed +13
-7
lines changed
arho_feature_template/core
2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change 1
1
from __future__ import annotations
2
2
3
- import json
4
3
from typing import TYPE_CHECKING , Sequence
5
4
6
5
from qgis .core import QgsMapLayer , QgsProject , QgsVectorLayer
7
6
from qgis .utils import iface
8
7
9
8
from arho_feature_template .core .feature_template import FeatureTemplate
10
9
from arho_feature_template .core .json_config import JsonKeys
10
+ from arho_feature_template .core .utils import read_json
11
11
12
12
if TYPE_CHECKING :
13
13
from os import PathLike
@@ -18,16 +18,11 @@ class FeatureTemplateLibrary:
18
18
19
19
def __init__ (self , json_path : str | PathLike ):
20
20
self .templates = []
21
- library_dict = self . read_json (json_path )
21
+ library_dict = read_json (json_path )
22
22
self .name = library_dict .get (JsonKeys .NAME )
23
23
self .version = library_dict .get (JsonKeys .VERSION )
24
24
self .build_templates (library_dict )
25
25
26
- def read_json (self , json_path : str | PathLike ) -> dict :
27
- self .source_json = json_path
28
- with open (json_path ) as f :
29
- return json .load (f )
30
-
31
26
def build_templates (self , library_dict : dict ):
32
27
"""Build feature templates from input `library_dict` and update `templates` attribute."""
33
28
all_templates_count = 0
Original file line number Diff line number Diff line change
1
+ import json
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ if TYPE_CHECKING :
6
+ from os import PathLike
7
+
8
+
9
+ def read_json (json_path : str | PathLike ) -> dict :
10
+ with open (json_path ) as f :
11
+ return json .load (f )
You can’t perform that action at this time.
0 commit comments