malac-utils 1.2.0__tar.gz → 1.3.0__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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: malac-utils
3
- Version: 1.2.0
3
+ Version: 1.3.0
4
4
  Summary: Mapping Language Compiler Utils
5
5
  Author-email: cdeHealth-Team <contact-project+cdehealth-malac-hd-52276676-issue-@incoming.gitlab.com>
6
6
  Project-URL: Homepage, https://gitlab.com/cdehealth/malac-hd
@@ -24,6 +24,7 @@ Requires-Python: >=3.10
24
24
  Description-Content-Type: text/markdown
25
25
  License-File: LICENSE
26
26
  Requires-Dist: python-dateutil>=2.8.2
27
+ Dynamic: license-file
27
28
 
28
29
  # MaLaC Utils
29
30
 
@@ -0,0 +1,2 @@
1
+
2
+ __version__ = "1.3.0"
@@ -10,6 +10,7 @@ class PartialDate:
10
10
  return self.value
11
11
 
12
12
  def parse(datestr):
13
+ datestr = getattr(datestr, "value", datestr)
13
14
  if re.search("^[0-9]{1,6}$", datestr):
14
15
  if len(datestr) > 4:
15
16
  return PartialDate(datestr[0:4] + "-" + datestr[4:])
@@ -18,4 +19,4 @@ def parse(datestr):
18
19
  elif len(datestr.split("-")) == 2:
19
20
  return PartialDate(datestr)
20
21
  else:
21
- return dateutil.parser.parse(datestr)
22
+ return dateutil.parser.parse(datestr)
@@ -121,6 +121,8 @@ class FHIRPathUtils(object):
121
121
  result = getattr(val, key[:-10]) or []
122
122
  if result != [] and len(attrs) == 1 and options.get("strip", False):
123
123
  result = str(result).strip()
124
+ if result == "":
125
+ result = []
124
126
  result = result if isinstance(result, list) else [result]
125
127
  if len(attrs) == 1:
126
128
  return result
@@ -130,7 +132,7 @@ class FHIRPathUtils(object):
130
132
  def string_value(self, val):
131
133
  if isinstance(val, str):
132
134
  return val
133
- elif isinstance(val, self.model.string) or isinstance(val, self.model.uri) or isinstance(val, self.model.code):
135
+ elif isinstance(val, self.model.string) or isinstance(val, self.model.uri) or isinstance(val, self.model.code) or isinstance(val, self.model.canonical) or isinstance(val, self.model.id):
134
136
  return val.value
135
137
  elif isinstance(val, self.model.div):
136
138
  tmp = io.StringIO()
@@ -505,7 +507,7 @@ class FHIRPathUtils(object):
505
507
  if val == [] or regex == []:
506
508
  return []
507
509
  else:
508
- return [re.fullmatch(val, regex)]
510
+ return [re.fullmatch(regex, val) is not None]
509
511
 
510
512
  def contains(self, val, other):
511
513
  val = self.string_value(val)
@@ -515,6 +517,24 @@ class FHIRPathUtils(object):
515
517
  else:
516
518
  return [other in val]
517
519
 
520
+ def replace(self, val, pattern, substitution):
521
+ val = self.string_value(val)
522
+ pattern = self.string_value(self.single_value(pattern, str, self.model.string))
523
+ substitution = self.string_value(self.single_value(substitution, str, self.model.string))
524
+ if val == [] or pattern == [] or substitution == []:
525
+ return []
526
+ else:
527
+ return [val.replace(pattern, substitution)]
528
+
529
+ def replaceMatches(self, val, regex, substitution):
530
+ val = self.string_value(val)
531
+ regex = self.string_value(self.single_value(regex, str, self.model.string))
532
+ substitution = self.string_value(self.single_value(substitution, str, self.model.string))
533
+ if val == [] or regex == [] or substitution == []:
534
+ return []
535
+ else:
536
+ return [re.sub(regex, substitution, val)]
537
+
518
538
  def startswith(self, val, other):
519
539
  val = self.string_value(val)
520
540
  other = self.string_value(self.single_value(other, str, self.model.string))
@@ -551,6 +571,13 @@ class FHIRPathUtils(object):
551
571
  if other == []:
552
572
  other = ""
553
573
  return [val + other]
574
+
575
+ def split(self, val, separator):
576
+ val = self.string_value(self.single_value(val))
577
+ separator = self.string_value(self.single_value(separator))
578
+ if val == [] or separator == []:
579
+ return []
580
+ return val.split(separator)
554
581
 
555
582
  def skip(self, val, count):
556
583
  count = self.single_value(count, int, self.model.integer)
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: malac-utils
3
- Version: 1.2.0
3
+ Version: 1.3.0
4
4
  Summary: Mapping Language Compiler Utils
5
5
  Author-email: cdeHealth-Team <contact-project+cdehealth-malac-hd-52276676-issue-@incoming.gitlab.com>
6
6
  Project-URL: Homepage, https://gitlab.com/cdehealth/malac-hd
@@ -24,6 +24,7 @@ Requires-Python: >=3.10
24
24
  Description-Content-Type: text/markdown
25
25
  License-File: LICENSE
26
26
  Requires-Dist: python-dateutil>=2.8.2
27
+ Dynamic: license-file
27
28
 
28
29
  # MaLaC Utils
29
30
 
@@ -1,5 +1,5 @@
1
1
  [build-system]
2
- requires = ["setuptools>=61.0.0,<69.3.0"]
2
+ requires = ["setuptools>=72.10"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
@@ -1,2 +0,0 @@
1
-
2
- __version__ = "1.2.0"
File without changes
File without changes
File without changes