commonlib-reader 1.0.6__tar.gz → 1.0.7__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.6 → commonlib_reader-1.0.7}/PKG-INFO +3 -3
- {commonlib_reader-1.0.6 → commonlib_reader-1.0.7}/commonlib_reader/facility.py +17 -5
- {commonlib_reader-1.0.6 → commonlib_reader-1.0.7}/commonlib_reader/ims.py +13 -7
- {commonlib_reader-1.0.6 → commonlib_reader-1.0.7}/pyproject.toml +4 -4
- {commonlib_reader-1.0.6 → commonlib_reader-1.0.7}/README.md +0 -0
- {commonlib_reader-1.0.6 → commonlib_reader-1.0.7}/commonlib_reader/__init__.py +0 -0
- {commonlib_reader-1.0.6 → commonlib_reader-1.0.7}/commonlib_reader/tag.py +0 -0
- {commonlib_reader-1.0.6 → commonlib_reader-1.0.7}/commonlib_reader/unit.py +0 -0
- {commonlib_reader-1.0.6 → commonlib_reader-1.0.7}/commonlib_reader/utils.py +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: commonlib-reader
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.7
|
|
4
4
|
Summary: Reader for Equinor commonlib api.
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Åsmund Våge Fannemel
|
|
7
7
|
Author-email: asmf@equinor.com
|
|
8
|
-
Requires-Python: >=3.
|
|
8
|
+
Requires-Python: >=3.10,<4.0.0
|
|
9
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.10
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.11
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
-
Requires-Dist:
|
|
15
|
+
Requires-Dist: eq-api-connector (>=0.1.7,<0.2.0)
|
|
16
16
|
Requires-Dist: pandas (>=2.1.4)
|
|
17
17
|
Requires-Dist: requests (>=2.32.4)
|
|
18
18
|
Requires-Dist: urllib3 (>=2.5.0)
|
|
@@ -41,14 +41,23 @@ class Facility:
|
|
|
41
41
|
self.name = self._data["name"]
|
|
42
42
|
self.description = self._data["description"]
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
self.SAPPlant = ""
|
|
45
|
+
self.Field = ""
|
|
46
|
+
self.ParentFacility = ""
|
|
47
|
+
self.NPDID = ""
|
|
47
48
|
|
|
48
49
|
for key, val in self._attributes.items():
|
|
49
|
-
if key in
|
|
50
|
+
if key in self.__getattribute__("__dict__").keys():
|
|
50
51
|
self.__setattr__(key, val)
|
|
51
52
|
|
|
53
|
+
self.STID = self.identity # Alias for identity
|
|
54
|
+
self.instCode = self.identity # Alias for identity
|
|
55
|
+
try:
|
|
56
|
+
self.SAP = int(self.SAPPlant) # Alias for SAPPlant as integer
|
|
57
|
+
except (TypeError, ValueError):
|
|
58
|
+
pass
|
|
59
|
+
|
|
60
|
+
|
|
52
61
|
def isSTID(self):
|
|
53
62
|
"""
|
|
54
63
|
Checks if the facility is marked for STID.
|
|
@@ -61,6 +70,9 @@ class Facility:
|
|
|
61
70
|
return True
|
|
62
71
|
|
|
63
72
|
return False
|
|
73
|
+
|
|
74
|
+
def __str__(self):
|
|
75
|
+
return f"Facility: {self.identity}, Name: {self.name}, Description: {self.description}"
|
|
64
76
|
|
|
65
77
|
@classmethod
|
|
66
78
|
def get_all_facilities(cls) -> List["Facility"]:
|
|
@@ -92,7 +104,7 @@ class Facility:
|
|
|
92
104
|
Retrieves the facility data for the given code.
|
|
93
105
|
|
|
94
106
|
Parameters:
|
|
95
|
-
code (str): The STID plant code corresponding to the facility.
|
|
107
|
+
code (str): The STID plant code corresponding to the facility. NB! SAP codes and governmental facility names can also be used.
|
|
96
108
|
|
|
97
109
|
Returns:
|
|
98
110
|
dict: A dictionary containing data related to the facility.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from typing import List, Union
|
|
2
|
+
from commonlib_reader.facility import Facility
|
|
2
3
|
from commonlib_reader.utils import attributes_list_to_dict, get_code
|
|
3
4
|
|
|
4
5
|
|
|
@@ -23,7 +24,7 @@ class IMS:
|
|
|
23
24
|
Raises:
|
|
24
25
|
ValueError: If input data is not a dict.
|
|
25
26
|
"""
|
|
26
|
-
if isinstance(data, str):
|
|
27
|
+
if isinstance(data, str) or isinstance(data, int):
|
|
27
28
|
data = IMS.from_facility(data)._data
|
|
28
29
|
|
|
29
30
|
if not isinstance(data, dict):
|
|
@@ -42,11 +43,11 @@ class IMS:
|
|
|
42
43
|
self.__setattr__(attr["definitionName"], attr["displayValue"])
|
|
43
44
|
|
|
44
45
|
@staticmethod
|
|
45
|
-
def from_facility(facility: str) -> "IMS":
|
|
46
|
+
def from_facility(facility: Union[Facility, str, int]) -> "IMS":
|
|
46
47
|
"""Get IMS instance from STID code.
|
|
47
48
|
|
|
48
49
|
Args:
|
|
49
|
-
facility (str): Facility code
|
|
50
|
+
facility (str): Facility inst code (STID) or SAP code.
|
|
50
51
|
|
|
51
52
|
Raises:
|
|
52
53
|
ValueError: Not able to instantiate IMS object from input facility code.
|
|
@@ -54,10 +55,15 @@ class IMS:
|
|
|
54
55
|
Returns:
|
|
55
56
|
IMS: IMS instance
|
|
56
57
|
"""
|
|
57
|
-
if facility
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
if isinstance(facility, int):
|
|
59
|
+
facility = Facility(facility).identity
|
|
60
|
+
|
|
61
|
+
if isinstance(facility, Facility):
|
|
62
|
+
facility = facility.identity
|
|
63
|
+
|
|
64
|
+
if not isinstance(facility, str) or len(facility) == 0:
|
|
65
|
+
raise ValueError("Not able to detect facility from input {facility}.")
|
|
66
|
+
|
|
61
67
|
ims = IMS.get_ims_list(facility=facility)
|
|
62
68
|
if len(ims) == 1:
|
|
63
69
|
return ims[0]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "commonlib-reader"
|
|
3
|
-
version = "1.0.
|
|
3
|
+
version = "1.0.7"
|
|
4
4
|
description = "Reader for Equinor commonlib api."
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "Åsmund Våge Fannemel", email = "asmf@equinor.com" }
|
|
@@ -8,12 +8,12 @@ authors = [
|
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
license = { text = "MIT" }
|
|
10
10
|
urls = {"Repository" = "https://github.com/equinor/commonlib-reader.git"}
|
|
11
|
-
requires-python = ">=3.
|
|
11
|
+
requires-python = ">=3.10,<4.0.0"
|
|
12
12
|
dependencies = [
|
|
13
|
-
"msal_bearer>=1.3.3,<2.0.0",
|
|
14
13
|
"pandas>=2.1.4",
|
|
15
14
|
"requests>=2.32.4",
|
|
16
|
-
"urllib3>=2.5.0" # Pinned to avoid security issues in some older versions
|
|
15
|
+
"urllib3>=2.5.0", # Pinned to avoid security issues in some older versions
|
|
16
|
+
"eq-api-connector (>=0.1.7,<0.2.0)"
|
|
17
17
|
]
|
|
18
18
|
|
|
19
19
|
[tool.poetry.group.test.dependencies]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|