pythermodb-settings 0.1.7__py3-none-any.whl → 0.1.8__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.
- pythermodb_settings/configs/about.py +1 -1
- pythermodb_settings/utils/component_utils.py +44 -5
- {pythermodb_settings-0.1.7.dist-info → pythermodb_settings-0.1.8.dist-info}/METADATA +1 -1
- {pythermodb_settings-0.1.7.dist-info → pythermodb_settings-0.1.8.dist-info}/RECORD +7 -7
- {pythermodb_settings-0.1.7.dist-info → pythermodb_settings-0.1.8.dist-info}/WHEEL +0 -0
- {pythermodb_settings-0.1.7.dist-info → pythermodb_settings-0.1.8.dist-info}/licenses/LICENSE +0 -0
- {pythermodb_settings-0.1.7.dist-info → pythermodb_settings-0.1.8.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
# NOTE: app info
|
2
|
-
__version__ = "0.1.
|
2
|
+
__version__ = "0.1.8"
|
3
3
|
__description__ = """PyThermoDB Settings is a Python package that acts as an interface between pythermdb and other applications, providing robust, Pydantic-based data models and configuration structures for managing thermodynamic database (ThermoDB) settings."""
|
4
4
|
__author__ = "Sina Gilassi"
|
5
5
|
__author_email__ = "sina.gilassi@gmail.com"
|
@@ -57,9 +57,15 @@ def create_component_id(
|
|
57
57
|
def set_component_id(
|
58
58
|
component: Component,
|
59
59
|
component_key: Literal[
|
60
|
-
'Name-State',
|
60
|
+
'Name-State',
|
61
|
+
'Formula-State',
|
62
|
+
'Name',
|
63
|
+
'Formula',
|
64
|
+
'Name-Formula-State',
|
65
|
+
'Formula-Name-State'
|
61
66
|
],
|
62
67
|
separator_symbol: str = '-',
|
68
|
+
case: Literal['lower', 'upper', None] = None
|
63
69
|
) -> str:
|
64
70
|
'''
|
65
71
|
Set component identifier based on the specified key.
|
@@ -73,9 +79,15 @@ def set_component_id(
|
|
73
79
|
Options are:
|
74
80
|
- 'Name-State': Use the name-state identifier.
|
75
81
|
- 'Formula-State': Use the formula-state identifier.
|
82
|
+
- 'Name': Use the component name.
|
83
|
+
- 'Formula': Use the component formula.
|
84
|
+
- 'Name-Formula-State': Use the name, formula, and state.
|
85
|
+
- 'Formula-Name-State': Use the formula, name, and state.
|
76
86
|
separator_symbol : str, optional
|
77
87
|
The symbol to use as a separator between the name/formula and state.
|
78
88
|
Default is '-'.
|
89
|
+
case : Literal['lower', 'upper', None], optional
|
90
|
+
Convert the identifier to lower or upper case.
|
79
91
|
|
80
92
|
Returns
|
81
93
|
-------
|
@@ -89,16 +101,43 @@ def set_component_id(
|
|
89
101
|
separator_symbol=separator_symbol
|
90
102
|
)
|
91
103
|
|
92
|
-
#
|
104
|
+
# init component id
|
105
|
+
component_id: str = ""
|
106
|
+
|
107
|
+
# NOTE: set component id
|
93
108
|
if component_key == "Name-State":
|
94
|
-
|
109
|
+
component_id = component_idx.name_state.strip()
|
95
110
|
elif component_key == "Formula-State":
|
96
|
-
|
111
|
+
component_id = component_idx.formula_state.strip()
|
112
|
+
elif component_key == "Name":
|
113
|
+
component_id = component.name.strip()
|
114
|
+
elif component_key == "Formula":
|
115
|
+
component_id = component.formula.strip()
|
116
|
+
elif component_key == "Name-Formula-State":
|
117
|
+
component_id = f"{component.name.strip()}{separator_symbol}{component.formula.strip()}{separator_symbol}{component.state.strip().lower()}"
|
118
|
+
elif component_key == "Formula-Name-State":
|
119
|
+
component_id = f"{component.formula.strip()}{separator_symbol}{component.name.strip()}{separator_symbol}{component.state.strip().lower()}"
|
97
120
|
else:
|
98
121
|
raise ValueError(
|
99
122
|
f"Invalid component_key '{component_key}'. "
|
100
123
|
f"Must be 'Name-State' or 'Formula-State'."
|
101
124
|
)
|
125
|
+
|
126
|
+
# NOTE: apply conversion
|
127
|
+
if case == 'lower':
|
128
|
+
component_id = component_id.lower()
|
129
|
+
elif case == 'upper':
|
130
|
+
component_id = component_id.upper()
|
131
|
+
elif case is None:
|
132
|
+
pass
|
133
|
+
else:
|
134
|
+
raise ValueError(
|
135
|
+
f"Invalid case '{case}'. "
|
136
|
+
f"Must be 'lower', 'upper', or None."
|
137
|
+
)
|
138
|
+
|
139
|
+
# result
|
140
|
+
return component_id
|
102
141
|
except Exception as e:
|
103
142
|
logger.error(
|
104
143
|
f"Failed to set component identifier for "
|
@@ -202,7 +241,7 @@ def create_mixture_id(
|
|
202
241
|
----------
|
203
242
|
components : list[Component]
|
204
243
|
List of components in the mixture.
|
205
|
-
component_key : Literal['Name', 'Formula'], optional
|
244
|
+
component_key : Literal['Name', 'Formula', 'Name-State', 'Formula-State'], optional
|
206
245
|
The key to use for identifying the components, by default 'Name'.
|
207
246
|
delimiter : str, optional
|
208
247
|
Delimiter to separate the components in the ID, by default "|".
|
@@ -1,7 +1,7 @@
|
|
1
1
|
pythermodb_settings/__init__.py,sha256=VzJSYgJJNw_j5NmnIbq0pJhBd_9Kp-bbfOsRLepplSw,229
|
2
2
|
pythermodb_settings/app.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
pythermodb_settings/configs/__init__.py,sha256=QR38PBCzgoFwYqcViR9bFT2YIR5m9s7q8C7cV4fZjz4,211
|
4
|
-
pythermodb_settings/configs/about.py,sha256=
|
4
|
+
pythermodb_settings/configs/about.py,sha256=EOoN8-XDp-zcjPXFWmqDzWIK4H5CHMDza326YaRuyBo,379
|
5
5
|
pythermodb_settings/models/__init__.py,sha256=4qi2Gut42auzeEpK4Gw0UkbALYlQ-kLnes0blSu_UFs,766
|
6
6
|
pythermodb_settings/models/components.py,sha256=4CwZcGpbm1PiEBQUpEmo6T6mP4y3S3LIiHCM0y9C7XU,1674
|
7
7
|
pythermodb_settings/models/conditions.py,sha256=Zm5JcM2kyMlS6b8hPbs6awa_6ps3xFoCVA4zwNPc5eg,1083
|
@@ -10,9 +10,9 @@ pythermodb_settings/models/references.py,sha256=A27Y-7L8X-g2m-pxuDk0ateFScPE1MME
|
|
10
10
|
pythermodb_settings/models/rules.py,sha256=1a9CyTHwpQkZQXFJWDMrEcKQAOTOwquepoOQPGznTlc,74
|
11
11
|
pythermodb_settings/models/source.py,sha256=0yU21YpYSqnew8rjTrlRuoWAuSAlUvMOebC5X0Sr8X4,1325
|
12
12
|
pythermodb_settings/utils/__init__.py,sha256=j3MYKYv7nx5u356J82cacKBzC-CBUJ8GPI4J3c5ss_U,277
|
13
|
-
pythermodb_settings/utils/component_utils.py,sha256=
|
14
|
-
pythermodb_settings-0.1.
|
15
|
-
pythermodb_settings-0.1.
|
16
|
-
pythermodb_settings-0.1.
|
17
|
-
pythermodb_settings-0.1.
|
18
|
-
pythermodb_settings-0.1.
|
13
|
+
pythermodb_settings/utils/component_utils.py,sha256=lR5dgq4kRDVN0e7uZM139UVAaUKejSbzFpHO9dboejY,10362
|
14
|
+
pythermodb_settings-0.1.8.dist-info/licenses/LICENSE,sha256=pHRAx3wjVKpt2ec3NyhntY6_bGgJqV2SyE8xNUJ7MYE,1090
|
15
|
+
pythermodb_settings-0.1.8.dist-info/METADATA,sha256=43RWZW6jsF9lrenPsoPPfhv9lcoeQbvPLAV3JYSI5PA,4894
|
16
|
+
pythermodb_settings-0.1.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
17
|
+
pythermodb_settings-0.1.8.dist-info/top_level.txt,sha256=6IdVIbW__wHFsKQYx7DDnXArm10qiJVIyaoSEFQylK4,20
|
18
|
+
pythermodb_settings-0.1.8.dist-info/RECORD,,
|
File without changes
|
{pythermodb_settings-0.1.7.dist-info → pythermodb_settings-0.1.8.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
File without changes
|