dkg 8.0.2__tar.gz → 8.0.11__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.
Files changed (82) hide show
  1. {dkg-8.0.2 → dkg-8.0.11}/PKG-INFO +2 -2
  2. {dkg-8.0.2 → dkg-8.0.11}/dkg/constants.py +13 -1
  3. {dkg-8.0.2 → dkg-8.0.11}/dkg/modules/asset/asset.py +1 -0
  4. {dkg-8.0.2 → dkg-8.0.11}/dkg/modules/asset/async_asset.py +1 -0
  5. {dkg-8.0.2 → dkg-8.0.11}/dkg/modules/graph/async_graph.py +1 -0
  6. {dkg-8.0.2 → dkg-8.0.11}/dkg/modules/graph/graph.py +1 -0
  7. {dkg-8.0.2 → dkg-8.0.11}/dkg/utils/knowledge_collection_tools.py +22 -2
  8. {dkg-8.0.2 → dkg-8.0.11}/pyproject.toml +1 -1
  9. {dkg-8.0.2 → dkg-8.0.11}/LICENSE +0 -0
  10. {dkg-8.0.2 → dkg-8.0.11}/NOTICE +0 -0
  11. {dkg-8.0.2 → dkg-8.0.11}/README.md +0 -0
  12. {dkg-8.0.2 → dkg-8.0.11}/dkg/__init__.py +0 -0
  13. {dkg-8.0.2 → dkg-8.0.11}/dkg/assertion.py +0 -0
  14. {dkg-8.0.2 → dkg-8.0.11}/dkg/clients/__init__.py +0 -0
  15. {dkg-8.0.2 → dkg-8.0.11}/dkg/clients/async_dkg.py +0 -0
  16. {dkg-8.0.2 → dkg-8.0.11}/dkg/clients/dkg.py +0 -0
  17. {dkg-8.0.2 → dkg-8.0.11}/dkg/data/interfaces/AskStorage.json +0 -0
  18. {dkg-8.0.2 → dkg-8.0.11}/dkg/data/interfaces/Chronos.json +0 -0
  19. {dkg-8.0.2 → dkg-8.0.11}/dkg/data/interfaces/Hub.json +0 -0
  20. {dkg-8.0.2 → dkg-8.0.11}/dkg/data/interfaces/IdentityStorage.json +0 -0
  21. {dkg-8.0.2 → dkg-8.0.11}/dkg/data/interfaces/KnowledgeCollection.json +0 -0
  22. {dkg-8.0.2 → dkg-8.0.11}/dkg/data/interfaces/KnowledgeCollectionStorage.json +0 -0
  23. {dkg-8.0.2 → dkg-8.0.11}/dkg/data/interfaces/Paranet.json +0 -0
  24. {dkg-8.0.2 → dkg-8.0.11}/dkg/data/interfaces/ParanetIncentivesPoolFactory.json +0 -0
  25. {dkg-8.0.2 → dkg-8.0.11}/dkg/data/interfaces/ParanetKnowledgeMinersRegistry.json +0 -0
  26. {dkg-8.0.2 → dkg-8.0.11}/dkg/data/interfaces/ParanetNeuroIncentivesPool.json +0 -0
  27. {dkg-8.0.2 → dkg-8.0.11}/dkg/data/interfaces/ParanetsRegistry.json +0 -0
  28. {dkg-8.0.2 → dkg-8.0.11}/dkg/data/interfaces/Token.json +0 -0
  29. {dkg-8.0.2 → dkg-8.0.11}/dkg/dataclasses.py +0 -0
  30. {dkg-8.0.2 → dkg-8.0.11}/dkg/exceptions.py +0 -0
  31. {dkg-8.0.2 → dkg-8.0.11}/dkg/managers/__init__.py +0 -0
  32. {dkg-8.0.2 → dkg-8.0.11}/dkg/managers/async_manager.py +0 -0
  33. {dkg-8.0.2 → dkg-8.0.11}/dkg/managers/manager.py +0 -0
  34. {dkg-8.0.2 → dkg-8.0.11}/dkg/method.py +0 -0
  35. {dkg-8.0.2 → dkg-8.0.11}/dkg/modules/__init__.py +0 -0
  36. {dkg-8.0.2 → dkg-8.0.11}/dkg/modules/asset/__init__.py +0 -0
  37. {dkg-8.0.2 → dkg-8.0.11}/dkg/modules/async_module.py +0 -0
  38. {dkg-8.0.2 → dkg-8.0.11}/dkg/modules/graph/__init__.py +0 -0
  39. {dkg-8.0.2 → dkg-8.0.11}/dkg/modules/module.py +0 -0
  40. {dkg-8.0.2 → dkg-8.0.11}/dkg/modules/network/__init__.py +0 -0
  41. {dkg-8.0.2 → dkg-8.0.11}/dkg/modules/network/network.py +0 -0
  42. {dkg-8.0.2 → dkg-8.0.11}/dkg/modules/node/__init__.py +0 -0
  43. {dkg-8.0.2 → dkg-8.0.11}/dkg/modules/node/async_node.py +0 -0
  44. {dkg-8.0.2 → dkg-8.0.11}/dkg/modules/node/node.py +0 -0
  45. {dkg-8.0.2 → dkg-8.0.11}/dkg/modules/paranet/__init__.py +0 -0
  46. {dkg-8.0.2 → dkg-8.0.11}/dkg/modules/paranet/paranet.py +0 -0
  47. {dkg-8.0.2 → dkg-8.0.11}/dkg/providers/__init__.py +0 -0
  48. {dkg-8.0.2 → dkg-8.0.11}/dkg/providers/blockchain/__init__.py +0 -0
  49. {dkg-8.0.2 → dkg-8.0.11}/dkg/providers/blockchain/async_blockchain.py +0 -0
  50. {dkg-8.0.2 → dkg-8.0.11}/dkg/providers/blockchain/base_blockchain.py +0 -0
  51. {dkg-8.0.2 → dkg-8.0.11}/dkg/providers/blockchain/blockchain.py +0 -0
  52. {dkg-8.0.2 → dkg-8.0.11}/dkg/providers/node/__init__.py +0 -0
  53. {dkg-8.0.2 → dkg-8.0.11}/dkg/providers/node/async_node_http.py +0 -0
  54. {dkg-8.0.2 → dkg-8.0.11}/dkg/providers/node/base_node_http.py +0 -0
  55. {dkg-8.0.2 → dkg-8.0.11}/dkg/providers/node/node_http.py +0 -0
  56. {dkg-8.0.2 → dkg-8.0.11}/dkg/services/__init__.py +0 -0
  57. {dkg-8.0.2 → dkg-8.0.11}/dkg/services/blockchain_services/__init__.py +0 -0
  58. {dkg-8.0.2 → dkg-8.0.11}/dkg/services/blockchain_services/async_blockchain_service.py +0 -0
  59. {dkg-8.0.2 → dkg-8.0.11}/dkg/services/blockchain_services/blockchain_service.py +0 -0
  60. {dkg-8.0.2 → dkg-8.0.11}/dkg/services/input_service.py +0 -0
  61. {dkg-8.0.2 → dkg-8.0.11}/dkg/services/node_services/__init__.py +0 -0
  62. {dkg-8.0.2 → dkg-8.0.11}/dkg/services/node_services/async_node_service.py +0 -0
  63. {dkg-8.0.2 → dkg-8.0.11}/dkg/services/node_services/node_service.py +0 -0
  64. {dkg-8.0.2 → dkg-8.0.11}/dkg/types/__init__.py +0 -0
  65. {dkg-8.0.2 → dkg-8.0.11}/dkg/types/blockchain.py +0 -0
  66. {dkg-8.0.2 → dkg-8.0.11}/dkg/types/dkg_node.py +0 -0
  67. {dkg-8.0.2 → dkg-8.0.11}/dkg/types/encoding.py +0 -0
  68. {dkg-8.0.2 → dkg-8.0.11}/dkg/types/evm.py +0 -0
  69. {dkg-8.0.2 → dkg-8.0.11}/dkg/types/general.py +0 -0
  70. {dkg-8.0.2 → dkg-8.0.11}/dkg/types/generics.py +0 -0
  71. {dkg-8.0.2 → dkg-8.0.11}/dkg/types/network.py +0 -0
  72. {dkg-8.0.2 → dkg-8.0.11}/dkg/types/rdf.py +0 -0
  73. {dkg-8.0.2 → dkg-8.0.11}/dkg/utils/__init__.py +0 -0
  74. {dkg-8.0.2 → dkg-8.0.11}/dkg/utils/blockchain_request.py +0 -0
  75. {dkg-8.0.2 → dkg-8.0.11}/dkg/utils/decorators.py +0 -0
  76. {dkg-8.0.2 → dkg-8.0.11}/dkg/utils/knowledge_asset_tools.py +0 -0
  77. {dkg-8.0.2 → dkg-8.0.11}/dkg/utils/merkle.py +0 -0
  78. {dkg-8.0.2 → dkg-8.0.11}/dkg/utils/metadata.py +0 -0
  79. {dkg-8.0.2 → dkg-8.0.11}/dkg/utils/node_request.py +0 -0
  80. {dkg-8.0.2 → dkg-8.0.11}/dkg/utils/rdf.py +0 -0
  81. {dkg-8.0.2 → dkg-8.0.11}/dkg/utils/string_transformations.py +0 -0
  82. {dkg-8.0.2 → dkg-8.0.11}/dkg/utils/ual.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: dkg
3
- Version: 8.0.2
3
+ Version: 8.0.11
4
4
  Summary: Python library for interacting with the OriginTrail Decentralized Knowledge Graph
5
5
  License: Apache-2.0
6
6
  Author: Uladzislau Hubar
@@ -35,6 +35,18 @@ CHUNK_BYTE_SIZE = 32
35
35
 
36
36
  MAX_FILE_SIZE = 10000000
37
37
 
38
+ ESCAPE_MAP = {
39
+ "\a": r"\a",
40
+ "\b": r"\b",
41
+ "\f": r"\f",
42
+ "\n": r"\n",
43
+ "\r": r"\r",
44
+ "\t": r"\t",
45
+ "\v": r"\v",
46
+ '"': r"\"",
47
+ "'": r"'",
48
+ }
49
+
38
50
 
39
51
  class DefaultParameters(Enum):
40
52
  ENVIRONMENT: str = "mainnet"
@@ -118,7 +130,7 @@ BLOCKCHAINS = {
118
130
  "rpc": "https://rpc.chiadochain.net",
119
131
  },
120
132
  "otp:20430": {
121
- "hub": "0xd7d073b560412c6A7F33dD670d323D01061E5DEb",
133
+ "hub": "0xE233B5b78853A62B1E11eBe88bF083e25b0a57a6",
122
134
  "rpc": "https://lofar-testnet.origin-trail.network",
123
135
  },
124
136
  },
@@ -209,6 +209,7 @@ class KnowledgeAsset(Module):
209
209
  blockchain_id = self.manager.blockchain_provider.blockchain_id
210
210
 
211
211
  dataset = {}
212
+ content = kc_tools.escape_literal_dict(content)
212
213
  public_content = dataset.get("public")
213
214
  private_content = dataset.get("private")
214
215
  if isinstance(content, str):
@@ -240,6 +240,7 @@ class AsyncKnowledgeAsset(AsyncModule):
240
240
  blockchain_id = self.manager.blockchain_provider.blockchain_id
241
241
 
242
242
  dataset = {}
243
+ content = kc_tools.escape_literal_dict(content)
243
244
  public_content = dataset.get("public")
244
245
  private_content = dataset.get("private")
245
246
  if isinstance(content, str):
@@ -57,6 +57,7 @@ class AsyncGraph(AsyncModule):
57
57
  result = await self.node_service.query(
58
58
  query, query_type, repository, paranet_ual
59
59
  )
60
+ result.encoding = "utf-8"
60
61
 
61
62
  return result.get("data")
62
63
 
@@ -50,6 +50,7 @@ class Graph(Module):
50
50
  query_type = parsed_query[1].name.replace("Query", "").upper()
51
51
 
52
52
  result = self.node_service.query(query, query_type, repository, paranet_ual)
53
+ result.encoding = "utf-8"
53
54
 
54
55
  return result.get("data")
55
56
 
@@ -1,9 +1,10 @@
1
1
  from typing import Literal
2
+ import codecs
2
3
  from dkg.constants import CHUNK_BYTE_SIZE
3
4
  from dkg.exceptions import DatasetInputFormatNotSupported, InvalidDataset
4
5
  from dkg.types import JSONLD, NQuads
5
6
  from pyld import jsonld
6
- from dkg.constants import DEFAULT_RDF_FORMAT, DEFAULT_CANON_ALGORITHM
7
+ from dkg.constants import DEFAULT_RDF_FORMAT, DEFAULT_CANON_ALGORITHM, ESCAPE_MAP
7
8
  from rdflib import Graph, BNode, URIRef, Literal as RDFLiteral
8
9
  from uuid import uuid4
9
10
  from web3 import Web3
@@ -96,7 +97,9 @@ def split_into_chunks(quads, chunk_size_bytes=32):
96
97
  while start < len(encoded_bytes):
97
98
  end = min(start + chunk_size_bytes, len(encoded_bytes))
98
99
  chunk = encoded_bytes[start:end]
99
- chunks.append(chunk.decode("utf-8")) # Decode bytes back to string
100
+ chunks.append(
101
+ codecs.decode(chunk, "utf-8", errors="replace")
102
+ ) # Decode bytes back to string
100
103
  start = end
101
104
 
102
105
  return chunks
@@ -246,3 +249,20 @@ def solidity_packed_sha256(types: list[str], values: list) -> str:
246
249
  sha256_hash = hashlib.sha256(packed_data).hexdigest()
247
250
 
248
251
  return f"0x{sha256_hash}"
252
+
253
+
254
+ def escape_literal_string(s):
255
+ for char, replacement in ESCAPE_MAP.items():
256
+ s = s.replace(char, replacement)
257
+ return s
258
+
259
+
260
+ def escape_literal_dict(obj):
261
+ if isinstance(obj, dict):
262
+ return {k: escape_literal_dict(v) for k, v in obj.items()}
263
+ elif isinstance(obj, list):
264
+ return [escape_literal_dict(i) for i in obj]
265
+ elif isinstance(obj, str):
266
+ return escape_literal_string(s=obj)
267
+ else:
268
+ return obj
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "dkg"
3
- version = "8.0.2"
3
+ version = "8.0.11"
4
4
  description = "Python library for interacting with the OriginTrail Decentralized Knowledge Graph"
5
5
  authors = ["Uladzislau Hubar <hubar.uladzislau@gmail.com>, Zvonimir Sculac <zvonimir.sculac@origin-trail.com>"]
6
6
  license = "Apache-2.0"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes