tiferet 1.0.0b3__py3-none-any.whl → 1.0.0b4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tiferet/proxies/yaml/__init__.py +79 -0
- tiferet/proxies/yaml/app.py +38 -18
- {tiferet-1.0.0b3.dist-info → tiferet-1.0.0b4.dist-info}/METADATA +1 -1
- {tiferet-1.0.0b3.dist-info → tiferet-1.0.0b4.dist-info}/RECORD +7 -7
- {tiferet-1.0.0b3.dist-info → tiferet-1.0.0b4.dist-info}/WHEEL +0 -0
- {tiferet-1.0.0b3.dist-info → tiferet-1.0.0b4.dist-info}/licenses/LICENSE +0 -0
- {tiferet-1.0.0b3.dist-info → tiferet-1.0.0b4.dist-info}/top_level.txt +0 -0
tiferet/proxies/yaml/__init__.py
CHANGED
@@ -0,0 +1,79 @@
|
|
1
|
+
# *** imports
|
2
|
+
|
3
|
+
# ** core
|
4
|
+
from typing import Dict, Any
|
5
|
+
|
6
|
+
# ** app
|
7
|
+
from ...commands import raise_error
|
8
|
+
from ...clients import yaml_client
|
9
|
+
|
10
|
+
|
11
|
+
# *** classes
|
12
|
+
|
13
|
+
# ** class yaml_proxy
|
14
|
+
class YamlProxy(object):
|
15
|
+
'''
|
16
|
+
A base class for YAML proxies.
|
17
|
+
'''
|
18
|
+
|
19
|
+
# * field: config_file
|
20
|
+
config_file: str = None
|
21
|
+
|
22
|
+
# * method: init
|
23
|
+
def __init__(self, config_file: str):
|
24
|
+
'''
|
25
|
+
Initialize the YAML proxy.
|
26
|
+
|
27
|
+
:param config_file: The configuration file.
|
28
|
+
:type config_file: str
|
29
|
+
'''
|
30
|
+
self.config_file = config_file
|
31
|
+
|
32
|
+
# * method: load_yaml
|
33
|
+
def load_yaml(self, start_node: str = None, create_data: callable = None) -> any:
|
34
|
+
'''
|
35
|
+
Load data from the YAML configuration file.
|
36
|
+
|
37
|
+
:param start_node: The starting node in the YAML file.
|
38
|
+
:type start_node: str
|
39
|
+
:param create_data: A callable to create data objects from the loaded data.
|
40
|
+
:type create_data: callable
|
41
|
+
:return: The loaded data.
|
42
|
+
:rtype: any
|
43
|
+
'''
|
44
|
+
|
45
|
+
# Load the YAML file using the yaml client.
|
46
|
+
try:
|
47
|
+
return yaml_client.load(
|
48
|
+
self.config_file,
|
49
|
+
create_data=create_data,
|
50
|
+
start_node=start_node
|
51
|
+
)
|
52
|
+
except FileNotFoundError as e:
|
53
|
+
# If the file is not found, raise an error.
|
54
|
+
raise_error.execute(
|
55
|
+
'CONFIG_FILE_NOT_FOUND',
|
56
|
+
f'Configuration file {self.config_file} not found.',
|
57
|
+
self.config_file
|
58
|
+
)
|
59
|
+
|
60
|
+
|
61
|
+
# * method: save_yaml
|
62
|
+
def save_yaml(self, data: Dict[str, Any]):
|
63
|
+
'''
|
64
|
+
Save data to the YAML configuration file.
|
65
|
+
|
66
|
+
:param data: The data to save.
|
67
|
+
:type data: Dict[str, Any]
|
68
|
+
'''
|
69
|
+
|
70
|
+
# Save the data to the YAML file using the yaml client.
|
71
|
+
try:
|
72
|
+
yaml_client.save(self.config_file, data)
|
73
|
+
except FileNotFoundError as e:
|
74
|
+
# If the file is not found, raise an error.
|
75
|
+
raise_error.execute(
|
76
|
+
'CONFIG_FILE_NOT_FOUND',
|
77
|
+
f'Configuration file {self.config_file} not found.',
|
78
|
+
self.config_file
|
79
|
+
)
|
tiferet/proxies/yaml/app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# *** imports
|
2
2
|
|
3
3
|
# ** app
|
4
|
+
from ...commands import raise_error
|
4
5
|
from ...data import DataObject
|
5
6
|
from ...data.app import AppInterfaceYamlData
|
6
7
|
from ...contracts.app import AppRepository, AppInterface
|
@@ -37,15 +38,24 @@ class AppYamlProxy(AppRepository):
|
|
37
38
|
'''
|
38
39
|
|
39
40
|
# Load the app interface data from the yaml configuration file and map it to the app interface object.
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
try:
|
42
|
+
interfaces = yaml_client.load(
|
43
|
+
self.config_file,
|
44
|
+
create_data=lambda data: [
|
45
|
+
DataObject.from_data(
|
46
|
+
AppInterfaceYamlData,
|
47
|
+
id=interface_id,
|
48
|
+
**record
|
49
|
+
).map() for interface_id, record in data.items()],
|
50
|
+
start_node=lambda data: data.get('interfaces'))
|
51
|
+
|
52
|
+
# If the file is not found, raise an error.
|
53
|
+
except FileNotFoundError:
|
54
|
+
raise_error.execute(
|
55
|
+
'APP_CONFIG_FILE_NOT_FOUND',
|
56
|
+
f'App configuration file {self.config_file} not found.',
|
57
|
+
self.config_file
|
58
|
+
)
|
49
59
|
|
50
60
|
# Return the list of app interface objects.
|
51
61
|
return interfaces
|
@@ -62,15 +72,25 @@ class AppYamlProxy(AppRepository):
|
|
62
72
|
'''
|
63
73
|
|
64
74
|
# Load the app interface data from the yaml configuration file.
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
75
|
+
try:
|
76
|
+
_data: AppInterface = yaml_client.load(
|
77
|
+
self.config_file,
|
78
|
+
create_data=lambda data: DataObject.from_data(
|
79
|
+
AppInterfaceYamlData,
|
80
|
+
id=id,
|
81
|
+
**data
|
82
|
+
),
|
83
|
+
start_node=lambda data: data.get('interfaces').get(id)
|
84
|
+
)
|
85
|
+
|
86
|
+
# If the file is not found, raise an error.
|
87
|
+
except FileNotFoundError:
|
88
|
+
raise_error.execute(
|
89
|
+
'APP_CONFIG_FILE_NOT_FOUND',
|
90
|
+
f'App configuration file {self.config_file} not found.',
|
91
|
+
self.config_file
|
92
|
+
)
|
93
|
+
|
74
94
|
# Return the app interface object.
|
75
95
|
# If the data is None, return None.
|
76
96
|
try:
|
@@ -40,13 +40,13 @@ tiferet/models/error.py,sha256=perVK1nfot8QVaowT3tUHlr-nh8Hy9E6rTE5p3Hhv28,5627
|
|
40
40
|
tiferet/models/feature.py,sha256=SDnK3WsisSh5cfaEcX0WXV1Y4N2WsaGfhkDl7NL9B6s,6423
|
41
41
|
tiferet/models/settings.py,sha256=nsdRY5IYv6TKxbBbxmpE6ujwmZxJPdF6VxlJkmt1P-k,2497
|
42
42
|
tiferet/proxies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
43
|
-
tiferet/proxies/yaml/__init__.py,sha256=
|
44
|
-
tiferet/proxies/yaml/app.py,sha256=
|
43
|
+
tiferet/proxies/yaml/__init__.py,sha256=rk_PyhBgbQ5mg62SPs1_JTJvXbaDJeoEsBl9SSqkfgs,2167
|
44
|
+
tiferet/proxies/yaml/app.py,sha256=Xg6nVojuSX2DjoSJYd1HJbYepZnjdiqvFczJWU8blvU,2998
|
45
45
|
tiferet/proxies/yaml/container.py,sha256=raOeZ2CIAbNHTzPNqL2tgPvuad7-LcPL0a1NJ-nmUYY,2971
|
46
46
|
tiferet/proxies/yaml/error.py,sha256=fFAFxbtVZ9dguvYb08TzrIBir1H0NYoe5JHjGm5HuTU,2885
|
47
47
|
tiferet/proxies/yaml/feature.py,sha256=CKIsAqil27U0VjtVIHTiq3U9chNOZM6HAuUyH5VDF_o,2471
|
48
|
-
tiferet-1.0.
|
49
|
-
tiferet-1.0.
|
50
|
-
tiferet-1.0.
|
51
|
-
tiferet-1.0.
|
52
|
-
tiferet-1.0.
|
48
|
+
tiferet-1.0.0b4.dist-info/licenses/LICENSE,sha256=e8_GutFM0sxbRlgUaeVsGvJ5uE-KvruLApOzIoHy_zU,1513
|
49
|
+
tiferet-1.0.0b4.dist-info/METADATA,sha256=QAHfiuwljCxrs65JxFkleNT4neHk2B5tEvLhrIxR5no,741
|
50
|
+
tiferet-1.0.0b4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
51
|
+
tiferet-1.0.0b4.dist-info/top_level.txt,sha256=g19Qw0j_VxPw-fgPF1TMPwbtHjnEhNQs0fa69wJZ6IM,8
|
52
|
+
tiferet-1.0.0b4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|