oli-python 2.0.3__tar.gz → 2.0.5__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
1
  Metadata-Version: 2.4
2
2
  Name: oli-python
3
- Version: 2.0.3
3
+ Version: 2.0.5
4
4
  Summary: Python SDK for interacting with the Open Labels Initiative; A standard, registry and trust layer for EVM address labels.
5
5
  Home-page: https://github.com/openlabelsinitiative/oli-python
6
6
  Author: Lorenz Lehmann
@@ -32,6 +32,8 @@ Dynamic: summary
32
32
 
33
33
  This SDK lets you read, write, validate, and revoke address labels within the **OLI Label Pool** and compute confidence scores based on attesters' relationships within the **OLI Label Trust**.
34
34
 
35
+ [Video Walkthrough](https://x.com/open_labels/status/1994353238699651328)
36
+
35
37
  ## Installation
36
38
 
37
39
  ```bash
@@ -4,6 +4,8 @@
4
4
 
5
5
  This SDK lets you read, write, validate, and revoke address labels within the **OLI Label Pool** and compute confidence scores based on attesters' relationships within the **OLI Label Trust**.
6
6
 
7
+ [Video Walkthrough](https://x.com/open_labels/status/1994353238699651328)
8
+
7
9
  ## Installation
8
10
 
9
11
  ```bash
@@ -26,9 +26,11 @@ class UtilsValidator:
26
26
  """
27
27
  Fix basic formatting in the tags dictionary. This includes:
28
28
  - Ensuring all tag_ids are lowercase
29
- - Booling values are converted from strings to booleans
30
29
  - Removing leading/trailing whitespace from string values
31
- - Checksum address (string(42)) tags
30
+ - Converting boolean values from strings/integers to booleans
31
+ (accepts: 'true'/'t'/'1'/1 for True, 'false'/'f'/'0'/0 for False, case-insensitive)
32
+ - Converting integer values from strings to integers
33
+ - Checksumming address (string(42)) tags
32
34
 
33
35
  Args:
34
36
  tags (dict): Dictionary of tags
@@ -39,17 +41,49 @@ class UtilsValidator:
39
41
  # Convert tag_ids to lowercase
40
42
  tags = {k.lower(): v for k, v in tags.items()}
41
43
 
42
- # Strip whitespaces, then turn boolean values from strings to booleans
44
+ # Strip whitespaces from strings
43
45
  for k, v in tags.items():
44
46
  if isinstance(v, str):
45
47
  tags[k] = v.strip()
46
- if tags[k] == 'true':
47
- tags[k] = True
48
- elif tags[k] == 'false':
49
- tags[k] = False
50
48
  elif isinstance(v, list):
51
49
  tags[k] = [i.strip() if isinstance(i, str) else i for i in v]
52
50
 
51
+ # Turn boolean strings to booleans based on schema
52
+ if self.oli.tag_definitions is not None:
53
+ boolean_keys = [
54
+ key
55
+ for key, value in self.oli.tag_definitions.items()
56
+ if value.get("schema", {}).get("type") == "boolean"
57
+ ]
58
+ for k, v in tags.items():
59
+ if k in boolean_keys:
60
+ if isinstance(v, str):
61
+ v_lower = v.lower()
62
+ if v_lower in ('true', 't', '1'):
63
+ tags[k] = True
64
+ elif v_lower in ('false', 'f', '0'):
65
+ tags[k] = False
66
+ elif isinstance(v, int):
67
+ if v == 1:
68
+ tags[k] = True
69
+ elif v == 0:
70
+ tags[k] = False
71
+
72
+ # Turn integer strings to integers based on schema
73
+ if self.oli.tag_definitions is not None:
74
+ integer_keys = [
75
+ key
76
+ for key, value in self.oli.tag_definitions.items()
77
+ if value.get("schema", {}).get("type") == "integer"
78
+ ]
79
+ for k, v in tags.items():
80
+ if k in integer_keys and isinstance(v, str):
81
+ if v.isdigit():
82
+ try:
83
+ tags[k] = int(v)
84
+ except ValueError:
85
+ pass
86
+
53
87
  # Checksum address tags
54
88
  for k, v in tags.items():
55
89
  if k in self.oli.tag_definitions and 'minLength' in self.oli.tag_definitions[k]['schema']:
@@ -215,7 +249,7 @@ class UtilsValidator:
215
249
  if len(self.oli.tag_value_sets[tag_id]) < 100:
216
250
  print(f"Please use one of the following values for {tag_id}: {self.oli.tag_value_sets[tag_id]}")
217
251
  else:
218
- print(f"Please use a valid value from the predefined value_set for {tag_id}: {self.oli.tag_definitions[tag_id]['value_set']}")
252
+ print(f"Please use a valid value from the predefined value_set for {tag_id}: oli.tag_value_sets['{tag_id}']")
219
253
  # list of values
220
254
  elif tags[tag_id] not in self.oli.tag_value_sets[tag_id] and isinstance(tags[tag_id], list):
221
255
  for i in tags[tag_id]:
@@ -224,7 +258,7 @@ class UtilsValidator:
224
258
  if len(self.oli.tag_value_sets[tag_id]) < 100:
225
259
  print(f"Please use a list of values from the predefined value_set for {tag_id}: {self.oli.tag_value_sets[tag_id]}")
226
260
  else:
227
- print(f"Please use a list of values from the predefined value_set for {tag_id}: {self.oli.tag_definitions[tag_id]['value_set']}")
261
+ print(f"Please use a list of values from the predefined value_set for {tag_id}: oli.tag_value_sets['{tag_id}']")
228
262
 
229
263
  def validate_ref_uid(self, ref_uid: str) -> bool:
230
264
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oli-python
3
- Version: 2.0.3
3
+ Version: 2.0.5
4
4
  Summary: Python SDK for interacting with the Open Labels Initiative; A standard, registry and trust layer for EVM address labels.
5
5
  Home-page: https://github.com/openlabelsinitiative/oli-python
6
6
  Author: Lorenz Lehmann
@@ -32,6 +32,8 @@ Dynamic: summary
32
32
 
33
33
  This SDK lets you read, write, validate, and revoke address labels within the **OLI Label Pool** and compute confidence scores based on attesters' relationships within the **OLI Label Trust**.
34
34
 
35
+ [Video Walkthrough](https://x.com/open_labels/status/1994353238699651328)
36
+
35
37
  ## Installation
36
38
 
37
39
  ```bash
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name="oli-python",
8
- version="2.0.3",
8
+ version="2.0.5",
9
9
  author="Lorenz Lehmann",
10
10
  author_email="lorenz@growthepie.com",
11
11
  description="Python SDK for interacting with the Open Labels Initiative; A standard, registry and trust layer for EVM address labels.",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes