commonlib-reader 1.0.8__tar.gz → 1.0.9__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.
- {commonlib_reader-1.0.8 → commonlib_reader-1.0.9}/PKG-INFO +1 -1
- {commonlib_reader-1.0.8 → commonlib_reader-1.0.9}/commonlib_reader/facility.py +24 -1
- {commonlib_reader-1.0.8 → commonlib_reader-1.0.9}/pyproject.toml +1 -1
- {commonlib_reader-1.0.8 → commonlib_reader-1.0.9}/README.md +0 -0
- {commonlib_reader-1.0.8 → commonlib_reader-1.0.9}/commonlib_reader/__init__.py +0 -0
- {commonlib_reader-1.0.8 → commonlib_reader-1.0.9}/commonlib_reader/connector.py +0 -0
- {commonlib_reader-1.0.8 → commonlib_reader-1.0.9}/commonlib_reader/ims.py +0 -0
- {commonlib_reader-1.0.8 → commonlib_reader-1.0.9}/commonlib_reader/tag.py +0 -0
- {commonlib_reader-1.0.8 → commonlib_reader-1.0.9}/commonlib_reader/unit.py +0 -0
- {commonlib_reader-1.0.8 → commonlib_reader-1.0.9}/commonlib_reader/utils.py +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import List
|
|
1
|
+
from typing import List, Union
|
|
2
2
|
|
|
3
3
|
from commonlib_reader.utils import attributes_list_to_dict, get_code
|
|
4
4
|
|
|
@@ -75,6 +75,29 @@ class Facility:
|
|
|
75
75
|
def __str__(self):
|
|
76
76
|
return f"Facility: {self.identity}, Name: {self.name}, Description: {self.description}"
|
|
77
77
|
|
|
78
|
+
@staticmethod
|
|
79
|
+
def get_inst_code(facility: Union[str, int]) -> str:
|
|
80
|
+
"""
|
|
81
|
+
Retrieves the STID installation code for the given facility identifier.
|
|
82
|
+
If the facility is not a STID facility, it recursively retrieves the installation code of its parent facility.
|
|
83
|
+
|
|
84
|
+
Parameters:
|
|
85
|
+
facility (str or int): The facility identifier, which can be a STID plant code, SAP code, or governmental facility name.
|
|
86
|
+
Returns:
|
|
87
|
+
str: The installation code corresponding to the facility.
|
|
88
|
+
Raises:
|
|
89
|
+
ValueError: If no facility is found for the provided identifier.
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
f = Facility(facility)
|
|
93
|
+
if isinstance(f, Facility):
|
|
94
|
+
if f.isSTID():
|
|
95
|
+
return f.STID
|
|
96
|
+
else:
|
|
97
|
+
return Facility.get_inst_code(f.ParentFacility)
|
|
98
|
+
|
|
99
|
+
raise ValueError(f"No facility found for {facility}")
|
|
100
|
+
|
|
78
101
|
@classmethod
|
|
79
102
|
def get_all_facilities(cls) -> List["Facility"]:
|
|
80
103
|
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|