crossplane-function-pythonic 0.3.0__py3-none-any.whl → 0.4.0__py3-none-any.whl

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.
@@ -37,21 +37,29 @@ def Unknown():
37
37
 
38
38
  def Yaml(string, readOnly=None):
39
39
  if isinstance(string, (FieldMessage, Value)):
40
+ if not string:
41
+ return string
40
42
  string = str(string)
41
43
  return Value(None, None, yaml.safe_load(string), readOnly)
42
44
 
43
45
  def Json(string, readOnly=None):
44
46
  if isinstance(string, (FieldMessage, Value)):
47
+ if not string:
48
+ return string
45
49
  string = str(string)
46
50
  return Value(None, None, json.loads(string), readOnly)
47
51
 
48
52
  def B64Encode(string):
49
53
  if isinstance(string, (FieldMessage, Value)):
54
+ if not string:
55
+ return string
50
56
  string = str(string)
51
57
  return base64.b64encode(string.encode('utf-8')).decode('utf-8')
52
58
 
53
59
  def B64Decode(string):
54
60
  if isinstance(string, (FieldMessage, Value)):
61
+ if not string:
62
+ return string
55
63
  string = str(string)
56
64
  return base64.b64decode(string.encode('utf-8')).decode('utf-8')
57
65
 
@@ -679,15 +687,28 @@ class Value:
679
687
  def _set_attribute(self, key, value):
680
688
  self.__dict__[key] = value
681
689
 
690
+ def __enter__(self):
691
+ return self
692
+
693
+ def __exit__(self, exc_type, exc_value, traceback):
694
+ pass
695
+
696
+ def __aenter__(self):
697
+ return self
698
+
699
+ def __aexit__(self, exc_type, exc_value, traceback):
700
+ pass
701
+
682
702
  def __getattr__(self, key):
683
703
  return self[key]
684
704
 
685
705
  def __getitem__(self, key):
686
706
  key = self._validate_key(key)
687
- if key in self._cache:
688
- return self._cache[key]
689
- if key in self._unknowns:
690
- return self._unknowns[key]
707
+ if key != append:
708
+ if key in self._cache:
709
+ return self._cache[key]
710
+ if key in self._unknowns:
711
+ return self._unknowns[key]
691
712
  if isinstance(key, str):
692
713
  match self._kind:
693
714
  case 'struct_value':
@@ -701,14 +722,26 @@ class Value:
701
722
  elif isinstance(key, int):
702
723
  match self._kind:
703
724
  case 'list_value':
725
+ if key < 0:
726
+ key = len(self._value.list_value.values) + key
727
+ if key < 0:
728
+ key = 0
704
729
  if key < len(self._value.list_value.values):
705
730
  value = self._value.list_value.values[key]
706
731
  else:
732
+ if key == append:
733
+ key = len(self._value.list_value.values)
707
734
  value = _Unknown
708
735
  case 'ListValue':
736
+ if key < 0:
737
+ key = len(self._value.values) + key
738
+ if key < 0:
739
+ key = 0
709
740
  if key < len(self._value.values):
710
741
  value = self._value.values[key]
711
742
  else:
743
+ if key == append:
744
+ key = len(self._value.values)
712
745
  value = _Unknown
713
746
  case 'Unknown':
714
747
  value = _Unknown
@@ -1246,7 +1279,6 @@ class Value:
1246
1279
  for key, value in self:
1247
1280
  if isinstance(value, Value) and len(value):
1248
1281
  patch = patches[key]
1249
- print(patch.__class__, str(patch))
1250
1282
  if isinstance(patch, Value) and patch._kind == value._kind and len(patch):
1251
1283
  value._patchUnknowns(patch)
1252
1284
  elif self._isList: