commonlib-reader 1.0.2__tar.gz → 1.0.3__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.2 → commonlib_reader-1.0.3}/PKG-INFO +1 -1
- {commonlib_reader-1.0.2 → commonlib_reader-1.0.3}/commonlib_reader/tag.py +19 -7
- {commonlib_reader-1.0.2 → commonlib_reader-1.0.3}/commonlib_reader/unit.py +1 -1
- {commonlib_reader-1.0.2 → commonlib_reader-1.0.3}/pyproject.toml +1 -1
- {commonlib_reader-1.0.2 → commonlib_reader-1.0.3}/README.md +0 -0
- {commonlib_reader-1.0.2 → commonlib_reader-1.0.3}/commonlib_reader/__init__.py +0 -0
- {commonlib_reader-1.0.2 → commonlib_reader-1.0.3}/commonlib_reader/facility.py +0 -0
- {commonlib_reader-1.0.2 → commonlib_reader-1.0.3}/commonlib_reader/ims.py +0 -0
- {commonlib_reader-1.0.2 → commonlib_reader-1.0.3}/commonlib_reader/utils.py +0 -0
|
@@ -22,7 +22,7 @@ class TagFormatElement:
|
|
|
22
22
|
|
|
23
23
|
"""
|
|
24
24
|
|
|
25
|
-
def __init__(self, data):
|
|
25
|
+
def __init__(self, data: dict):
|
|
26
26
|
"""
|
|
27
27
|
Initializes a TagFormatElement object.
|
|
28
28
|
|
|
@@ -134,14 +134,26 @@ class TagFormat:
|
|
|
134
134
|
|
|
135
135
|
return self._tfe
|
|
136
136
|
|
|
137
|
-
def
|
|
138
|
-
|
|
139
|
-
py_pattern = re.sub(r"\(\?<(\w+)>", r"(?P<\1>", self.regex_grouped)
|
|
137
|
+
def get_regex_grouped_named(self) -> str:
|
|
138
|
+
"""Substitute codes with descriptions in grouped regex
|
|
140
139
|
|
|
141
|
-
|
|
140
|
+
Returns:
|
|
141
|
+
str: Regex grouped string where generic regex group names are replaced with tag format element description.
|
|
142
|
+
"""
|
|
143
|
+
regex_group_named = self.regex_grouped
|
|
144
|
+
for e in self.get_tagformat_elements():
|
|
145
|
+
regex_group_named = regex_group_named.replace(
|
|
146
|
+
f"?<e{e.name}>", f"?<{e.description}>"
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
return regex_group_named
|
|
142
150
|
|
|
151
|
+
def split_tag(self, tagNo: str) -> dict:
|
|
152
|
+
# Change naming pattern for groups in commonlib-regex to match python re format
|
|
153
|
+
py_pattern = re.sub(r"\(\?<(\w+)>", r"(?P<\1>", self.regex_grouped)
|
|
143
154
|
matches = re.match(py_pattern, tagNo)
|
|
144
155
|
|
|
156
|
+
# Tag format element descriptions may contain space and can not be used as group name in regex. Instead create dict where description is key.
|
|
145
157
|
d = {}
|
|
146
158
|
for e in self.get_tagformat_elements():
|
|
147
159
|
group_name = f"e{e.name}"
|
|
@@ -458,7 +470,7 @@ class TagCategory:
|
|
|
458
470
|
return f"{self.TagCategoryId}:{self.name} - {self.description}"
|
|
459
471
|
|
|
460
472
|
@staticmethod
|
|
461
|
-
def get_category(inst_code, name="") -> List["TagCategory"]:
|
|
473
|
+
def get_category(inst_code: str, name="") -> List["TagCategory"]:
|
|
462
474
|
categories = _get_category_data(inst_code=inst_code)
|
|
463
475
|
tc = [TagCategory(x, inst_code=inst_code) for x in categories]
|
|
464
476
|
tc.sort(key=lambda x: x.TagCategoryId)
|
|
@@ -470,7 +482,7 @@ class TagCategory:
|
|
|
470
482
|
return tc
|
|
471
483
|
|
|
472
484
|
|
|
473
|
-
def _get_category_data(inst_code) -> List[dict]:
|
|
485
|
+
def _get_category_data(inst_code: str) -> List[dict]:
|
|
474
486
|
"""Get code table of tag categories for a facility from commonlibapi.
|
|
475
487
|
|
|
476
488
|
Args:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|