kodexa 7.4.418571405824__py3-none-any.whl → 7.4.418571517744__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.

Potentially problematic release.


This version of kodexa might be problematic. Click here for more details.

kodexa/model/model.py CHANGED
@@ -14,7 +14,7 @@ import deepdiff
14
14
  import msgpack
15
15
  from pydantic import BaseModel, ConfigDict, Field
16
16
 
17
- from kodexa.model.objects import ContentObject, FeatureSet, DocumentTaxonValidation
17
+ from kodexa.model.objects import ContentObject, FeatureSet, DocumentTaxonValidation, KnowledgeItem
18
18
 
19
19
 
20
20
  class Ref:
@@ -2503,6 +2503,12 @@ class Document(object):
2503
2503
  def set_steps(self, steps: list[ProcessingStep]):
2504
2504
  self._persistence_layer.set_steps(steps)
2505
2505
 
2506
+ def get_knowledge(self) -> list[KnowledgeItem]:
2507
+ return self._persistence_layer.get_knowledge()
2508
+
2509
+ def set_knowledge(self, knowledge: list[KnowledgeItem]):
2510
+ self._persistence_layer.set_knowledge(knowledge)
2511
+
2506
2512
  def replace_exceptions(self, exceptions: List[ContentException]):
2507
2513
  self._persistence_layer.replace_exceptions(exceptions)
2508
2514
 
@@ -1369,6 +1369,51 @@ class SqliteDocumentPersistence(object):
1369
1369
  return [ProcessingStep(**step) for step in unpacked_data]
1370
1370
  return []
1371
1371
 
1372
+ def __ensure_knowledge_table_exists(self):
1373
+ """
1374
+ Ensure the 'knowledge' table exists in the database.
1375
+ Creates the table if it does not exist.
1376
+ """
1377
+ self.cursor.execute("""
1378
+ CREATE TABLE IF NOT EXISTS knowledge (
1379
+ obj BLOB
1380
+ )
1381
+ """)
1382
+
1383
+ # Check if the table has any rows, if not, insert an initial empty row
1384
+ result = self.cursor.execute("SELECT COUNT(*) FROM knowledge").fetchone()
1385
+ if result[0] == 0:
1386
+ self.cursor.execute("INSERT INTO knowledge (obj) VALUES (?)", [sqlite3.Binary(msgpack.packb([]))])
1387
+
1388
+ def set_knowledge(self, knowledge: List):
1389
+ """
1390
+ Sets the knowledge items for the document.
1391
+
1392
+ Args:
1393
+ knowledge (List): A list of KnowledgeItem objects to store.
1394
+ """
1395
+ from kodexa.model.objects import KnowledgeItem
1396
+ self.__ensure_knowledge_table_exists()
1397
+ serialized_knowledge = [item.model_dump(by_alias=True) for item in knowledge]
1398
+ packed_data = sqlite3.Binary(msgpack.packb(serialized_knowledge))
1399
+ self.cursor.execute("UPDATE knowledge SET obj = ? WHERE rowid = 1", [packed_data])
1400
+ self.connection.commit()
1401
+
1402
+ def get_knowledge(self) -> List:
1403
+ """
1404
+ Gets the knowledge items associated with this document.
1405
+
1406
+ Returns:
1407
+ List: A list of KnowledgeItem objects.
1408
+ """
1409
+ from kodexa.model.objects import KnowledgeItem
1410
+ self.__ensure_knowledge_table_exists()
1411
+ result = self.cursor.execute("SELECT obj FROM knowledge WHERE rowid = 1").fetchone()
1412
+ if result and result[0]:
1413
+ unpacked_data = msgpack.unpackb(result[0])
1414
+ return [KnowledgeItem(**item) for item in unpacked_data]
1415
+ return []
1416
+
1372
1417
 
1373
1418
  class SimpleObjectCache(object):
1374
1419
  """
@@ -1518,6 +1563,22 @@ class PersistenceManager(object):
1518
1563
  def set_steps(self, steps: list[ProcessingStep]):
1519
1564
  self._underlying_persistence.set_steps(steps)
1520
1565
 
1566
+ def get_knowledge(self) -> list:
1567
+ """
1568
+ Gets the knowledge items for this document
1569
+
1570
+ :return: list of KnowledgeItem objects
1571
+ """
1572
+ return self._underlying_persistence.get_knowledge()
1573
+
1574
+ def set_knowledge(self, knowledge: list):
1575
+ """
1576
+ Sets the knowledge items for this document
1577
+
1578
+ :param knowledge: list of KnowledgeItem objects
1579
+ """
1580
+ self._underlying_persistence.set_knowledge(knowledge)
1581
+
1521
1582
  def set_validations(self, validations: list[DocumentTaxonValidation]):
1522
1583
  self._underlying_persistence.set_validations(validations)
1523
1584
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kodexa
3
- Version: 7.4.418571405824
3
+ Version: 7.4.418571517744
4
4
  Summary: Python SDK for the Kodexa Platform
5
5
  License-File: LICENSE
6
6
  Author: Austin Redenbaugh
@@ -12,9 +12,9 @@ kodexa/model/entities/check_response.py,sha256=eqBHxO6G2OAziL3p9bHGI-oiPkAG82H6C
12
12
  kodexa/model/entities/product.py,sha256=StUhTEeLXmc05cj6XnZppQfeJsqCPbX1jdhsysHH--Q,5787
13
13
  kodexa/model/entities/product_group.py,sha256=540fRGyUf34h1BzAN1DiWu6rGgvaj3xDFhZ2k-RvSFY,3617
14
14
  kodexa/model/entities/product_subscription.py,sha256=UcmWR-qgLfdV7VCtJNwzgkanoS8nBSL6ngVuxQUK1M8,3810
15
- kodexa/model/model.py,sha256=o93SDgw8mj28LWbwJB78PF_Oim8qeCTH1a9x_GDc7yg,120895
15
+ kodexa/model/model.py,sha256=FA4QkAbtHln6KkHq7GV82oP2eXQnxvJ_mHhhNQwUS-w,121137
16
16
  kodexa/model/objects.py,sha256=b5aicXaZpbej6inkessxh6_8R9LYsSiTlfferTZ4Rqs,215954
17
- kodexa/model/persistence.py,sha256=n5KfdyujKmBWc-x_LN0pmRpFCo50VSrTr4_1M98q6tc,73548
17
+ kodexa/model/persistence.py,sha256=IWPJk2t_1vHjkWBtK61en-7aVM74zElZM4ciF-NdS2g,75802
18
18
  kodexa/model/utils.py,sha256=YEG3f8YzBil06D0P3_dfx2S9GnHREzyrjnlWwQ7oPlU,3038
19
19
  kodexa/pipeline/__init__.py,sha256=sA7f5D6qkdMrpp2xTIeefnrUBI6xxEEWostvxfX_1Cs,236
20
20
  kodexa/pipeline/pipeline.py,sha256=zyNEpA7KlGhPs_l-vgV6m-OCb16dbxQhl8QezeylugA,25540
@@ -45,7 +45,7 @@ kodexa/testing/test_utils.py,sha256=v44p__gE7ia67W7WeHN2HBFCWSCUrCZt7G4xBNCmwf8,
45
45
  kodexa/training/__init__.py,sha256=xs2L62YpRkIRfslQwtQZ5Yxjhm7sLzX2TrVX6EuBnZQ,52
46
46
  kodexa/training/train_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
47
  kodexa/utils/__init__.py,sha256=Pnim1o9_db5YEnNvDTxpM7HG-qTlL6n8JwFwOafU9wo,5928
48
- kodexa-7.4.418571405824.dist-info/METADATA,sha256=oKfJGb6Xwi307kY0yJE8lfk08VtIJWk5B2LXgEEvmCo,2938
49
- kodexa-7.4.418571405824.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
50
- kodexa-7.4.418571405824.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
51
- kodexa-7.4.418571405824.dist-info/RECORD,,
48
+ kodexa-7.4.418571517744.dist-info/METADATA,sha256=8IMookIT0Kfyz_UXEVH7DnFgum7dNR76sSBl70fALrk,2938
49
+ kodexa-7.4.418571517744.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
50
+ kodexa-7.4.418571517744.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
51
+ kodexa-7.4.418571517744.dist-info/RECORD,,