pythermodb-settings 0.1.0__tar.gz → 0.1.2__tar.gz

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.
Files changed (23) hide show
  1. {pythermodb_settings-0.1.0/pythermodb_settings.egg-info → pythermodb_settings-0.1.2}/PKG-INFO +1 -1
  2. {pythermodb_settings-0.1.0 → pythermodb_settings-0.1.2}/pyproject.toml +1 -1
  3. {pythermodb_settings-0.1.0 → pythermodb_settings-0.1.2}/pythermodb_settings/configs/about.py +1 -1
  4. {pythermodb_settings-0.1.0 → pythermodb_settings-0.1.2}/pythermodb_settings/models/__init__.py +5 -2
  5. {pythermodb_settings-0.1.0 → pythermodb_settings-0.1.2}/pythermodb_settings/models/components.py +21 -0
  6. pythermodb_settings-0.1.2/pythermodb_settings/models/source.py +28 -0
  7. pythermodb_settings-0.1.2/pythermodb_settings/utils/__init__.py +7 -0
  8. pythermodb_settings-0.1.2/pythermodb_settings/utils/component_utils.py +107 -0
  9. {pythermodb_settings-0.1.0 → pythermodb_settings-0.1.2/pythermodb_settings.egg-info}/PKG-INFO +1 -1
  10. {pythermodb_settings-0.1.0 → pythermodb_settings-0.1.2}/pythermodb_settings.egg-info/SOURCES.txt +4 -1
  11. {pythermodb_settings-0.1.0 → pythermodb_settings-0.1.2}/LICENSE +0 -0
  12. {pythermodb_settings-0.1.0 → pythermodb_settings-0.1.2}/README.md +0 -0
  13. {pythermodb_settings-0.1.0 → pythermodb_settings-0.1.2}/pythermodb_settings/__init__.py +0 -0
  14. {pythermodb_settings-0.1.0 → pythermodb_settings-0.1.2}/pythermodb_settings/app.py +0 -0
  15. {pythermodb_settings-0.1.0 → pythermodb_settings-0.1.2}/pythermodb_settings/configs/__init__.py +0 -0
  16. {pythermodb_settings-0.1.0 → pythermodb_settings-0.1.2}/pythermodb_settings/models/conditions.py +0 -0
  17. {pythermodb_settings-0.1.0 → pythermodb_settings-0.1.2}/pythermodb_settings/models/configs.py +0 -0
  18. {pythermodb_settings-0.1.0 → pythermodb_settings-0.1.2}/pythermodb_settings/models/references.py +0 -0
  19. {pythermodb_settings-0.1.0 → pythermodb_settings-0.1.2}/pythermodb_settings/models/rules.py +0 -0
  20. {pythermodb_settings-0.1.0 → pythermodb_settings-0.1.2}/pythermodb_settings.egg-info/dependency_links.txt +0 -0
  21. {pythermodb_settings-0.1.0 → pythermodb_settings-0.1.2}/pythermodb_settings.egg-info/requires.txt +0 -0
  22. {pythermodb_settings-0.1.0 → pythermodb_settings-0.1.2}/pythermodb_settings.egg-info/top_level.txt +0 -0
  23. {pythermodb_settings-0.1.0 → pythermodb_settings-0.1.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythermodb-settings
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Add your description here
5
5
  Author-email: Sina Gilassi <sina.gilassi@gmail.com>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pythermodb-settings"
7
- version = "0.1.0"
7
+ version = "0.1.2"
8
8
  description = "Add your description here"
9
9
  authors = [
10
10
  { name = "Sina Gilassi", email = "sina.gilassi@gmail.com" }
@@ -1,5 +1,5 @@
1
1
  # NOTE: app info
2
- __version__ = "0.1.0"
2
+ __version__ = "0.1.2"
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"
@@ -1,5 +1,5 @@
1
1
  # export
2
- from .components import Component
2
+ from .components import Component, ComponentIdentity
3
3
  from .conditions import Temperature, Pressure
4
4
  from .configs import ComponentConfig
5
5
  from .references import (
@@ -9,9 +9,11 @@ from .references import (
9
9
  CustomReference
10
10
  )
11
11
  from .rules import ComponentRule
12
+ from .source import ComponentThermoDBSource
12
13
 
13
14
  __all__ = [
14
15
  "Component",
16
+ "ComponentIdentity",
15
17
  "Temperature",
16
18
  "Pressure",
17
19
  "ComponentConfig",
@@ -19,5 +21,6 @@ __all__ = [
19
21
  "ComponentReferenceThermoDB",
20
22
  "ReferencesThermoDB",
21
23
  "CustomReference",
22
- "ComponentRule"
24
+ "ComponentRule",
25
+ "ComponentThermoDBSource"
23
26
  ]
@@ -39,3 +39,24 @@ class Component(BaseModel):
39
39
  arbitrary_types_allowed=True,
40
40
  extra="allow"
41
41
  )
42
+
43
+
44
+ class ComponentIdentity(BaseModel):
45
+ """
46
+ Model for component identity.
47
+
48
+ Attributes
49
+ ----------
50
+ name_state : str
51
+ Component name-state identifier.
52
+ formula_state : str
53
+ Component formula-state identifier.
54
+ """
55
+ name_state: str = Field(
56
+ ...,
57
+ description="Component name-state identifier"
58
+ )
59
+ formula_state: str = Field(
60
+ ...,
61
+ description="Component formula-state identifier"
62
+ )
@@ -0,0 +1,28 @@
1
+ # import libs
2
+ from pydantic import (
3
+ BaseModel,
4
+ Field,
5
+ ConfigDict
6
+ )
7
+ # local
8
+ from .components import Component
9
+
10
+
11
+ class ComponentThermoDBSource(BaseModel):
12
+ '''
13
+ ThermoDB source containing component thermodb.
14
+
15
+ Attributes
16
+ ----------
17
+ component: Component
18
+ Component thermodb
19
+ source: str
20
+ Path to the thermodb file
21
+ '''
22
+ component: Component
23
+ source: str
24
+
25
+ model_config = ConfigDict(
26
+ arbitrary_types_allowed=True,
27
+ extra="allow"
28
+ )
@@ -0,0 +1,7 @@
1
+ # export
2
+ from .component_utils import create_component_id, set_component_id
3
+
4
+ __all__ = [
5
+ "create_component_id",
6
+ "set_component_id"
7
+ ]
@@ -0,0 +1,107 @@
1
+ # import libs
2
+ import logging
3
+ from typing import Literal
4
+ from pythermodb_settings.models import Component
5
+ # local
6
+ from ..models import ComponentIdentity
7
+
8
+ # NOTE: logger
9
+ logger = logging.getLogger(__name__)
10
+
11
+
12
+ def create_component_id(
13
+ component: Component,
14
+ separator_symbol: str = '-'
15
+ ) -> ComponentIdentity:
16
+ '''
17
+ Create component name-state and formula-state identifiers.
18
+
19
+ Parameters
20
+ ----------
21
+ component : Component
22
+ The component for which to create the identifiers.
23
+ separator_symbol : str, optional
24
+ The symbol to use as a separator between the name/formula and
25
+
26
+ Returns
27
+ -------
28
+ ComponentIdentity
29
+ The component identity containing name-state and formula-state
30
+ identifiers.
31
+ '''
32
+ try:
33
+ # NOTE: extract component name
34
+ component_name = component.name.strip()
35
+ component_formula = component.formula.strip()
36
+ component_state = component.state.strip().lower()
37
+
38
+ # >> separator
39
+ separator_symbol = separator_symbol.strip()
40
+
41
+ # SECTION: create component identifiers
42
+ name_state = f"{component_name}{separator_symbol}{component_state}"
43
+ formula_state = f"{component_formula}{separator_symbol}{component_state}"
44
+
45
+ return ComponentIdentity(
46
+ name_state=name_state,
47
+ formula_state=formula_state
48
+ )
49
+ except Exception as e:
50
+ logger.error(
51
+ f"Failed to create component identifiers for "
52
+ f"'{component}': {e}"
53
+ )
54
+ raise e
55
+
56
+
57
+ def set_component_id(
58
+ component: Component,
59
+ component_key: Literal[
60
+ 'Name-State', 'Formula-State'
61
+ ],
62
+ separator_symbol: str = '-',
63
+ ) -> str:
64
+ '''
65
+ Set component identifier based on the specified key.
66
+
67
+ Parameters
68
+ ----------
69
+ component : Component
70
+ The component for which to set the identifier.
71
+ component_key : str
72
+ The key to determine which identifier to use.
73
+ Options are:
74
+ - 'Name-State': Use the name-state identifier.
75
+ - 'Formula-State': Use the formula-state identifier.
76
+ separator_symbol : str, optional
77
+ The symbol to use as a separator between the name/formula and state.
78
+ Default is '-'.
79
+
80
+ Returns
81
+ -------
82
+ str
83
+ The component identifier based on the specified key.
84
+ '''
85
+ try:
86
+ # NOTE: create component id
87
+ component_idx: ComponentIdentity = create_component_id(
88
+ component=component,
89
+ separator_symbol=separator_symbol
90
+ )
91
+
92
+ # set component id
93
+ if component_key == "Name-State":
94
+ return component_idx.name_state
95
+ elif component_key == "Formula-State":
96
+ return component_idx.formula_state
97
+ else:
98
+ raise ValueError(
99
+ f"Invalid component_key '{component_key}'. "
100
+ f"Must be 'Name-State' or 'Formula-State'."
101
+ )
102
+ except Exception as e:
103
+ logger.error(
104
+ f"Failed to set component identifier for "
105
+ f"'{component}': {e}"
106
+ )
107
+ raise e
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythermodb-settings
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Add your description here
5
5
  Author-email: Sina Gilassi <sina.gilassi@gmail.com>
6
6
  License-Expression: MIT
@@ -15,4 +15,7 @@ pythermodb_settings/models/components.py
15
15
  pythermodb_settings/models/conditions.py
16
16
  pythermodb_settings/models/configs.py
17
17
  pythermodb_settings/models/references.py
18
- pythermodb_settings/models/rules.py
18
+ pythermodb_settings/models/rules.py
19
+ pythermodb_settings/models/source.py
20
+ pythermodb_settings/utils/__init__.py
21
+ pythermodb_settings/utils/component_utils.py