kodexa 7.0.12399293688__py3-none-any.whl → 7.4.412416252968__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.
- kodexa/model/model.py +7 -4
- kodexa/model/persistence.py +87 -27
- {kodexa-7.0.12399293688.dist-info → kodexa-7.4.412416252968.dist-info}/METADATA +1 -1
- {kodexa-7.0.12399293688.dist-info → kodexa-7.4.412416252968.dist-info}/RECORD +6 -6
- {kodexa-7.0.12399293688.dist-info → kodexa-7.4.412416252968.dist-info}/LICENSE +0 -0
- {kodexa-7.0.12399293688.dist-info → kodexa-7.4.412416252968.dist-info}/WHEEL +0 -0
kodexa/model/model.py
CHANGED
@@ -2443,11 +2443,14 @@ class Document(object):
|
|
2443
2443
|
def get_exceptions(self) -> List[ContentException]:
|
2444
2444
|
return self._persistence_layer.get_exceptions()
|
2445
2445
|
|
2446
|
-
def get_external_data(self) -> dict:
|
2447
|
-
return self._persistence_layer.get_external_data()
|
2446
|
+
def get_external_data(self, key="default") -> dict:
|
2447
|
+
return self._persistence_layer.get_external_data(key)
|
2448
2448
|
|
2449
|
-
def
|
2450
|
-
return self._persistence_layer.
|
2449
|
+
def get_external_data_keys(self) -> list[str]:
|
2450
|
+
return self._persistence_layer.get_external_data_keys()
|
2451
|
+
|
2452
|
+
def set_external_data(self, external_data:dict, key="default"):
|
2453
|
+
return self._persistence_layer.set_external_data(external_data, key)
|
2451
2454
|
|
2452
2455
|
def get_steps(self) -> list[ProcessingStep]:
|
2453
2456
|
return self._persistence_layer.get_steps()
|
kodexa/model/persistence.py
CHANGED
@@ -1156,22 +1156,6 @@ class SqliteDocumentPersistence(object):
|
|
1156
1156
|
|
1157
1157
|
return content_nodes
|
1158
1158
|
|
1159
|
-
def __ensure_ed_table_exists(self):
|
1160
|
-
"""
|
1161
|
-
Ensure the 'ed' table exists in the database.
|
1162
|
-
Creates the table if it does not exist.
|
1163
|
-
"""
|
1164
|
-
self.cursor.execute("""
|
1165
|
-
CREATE TABLE IF NOT EXISTS ed (
|
1166
|
-
obj BLOB
|
1167
|
-
)
|
1168
|
-
""")
|
1169
|
-
|
1170
|
-
# Check if the table has any rows, if not, insert an initial empty row
|
1171
|
-
result = self.cursor.execute("SELECT COUNT(*) FROM ed").fetchone()
|
1172
|
-
if result[0] == 0:
|
1173
|
-
self.cursor.execute("INSERT INTO ed (obj) VALUES (?)", [sqlite3.Binary(msgpack.packb({}))])
|
1174
|
-
|
1175
1159
|
def __ensure_validations_table_exists(self):
|
1176
1160
|
"""
|
1177
1161
|
Ensure the 'validations' table exists in the database.
|
@@ -1213,31 +1197,98 @@ class SqliteDocumentPersistence(object):
|
|
1213
1197
|
return [DocumentTaxonValidation.model_validate(v) for v in msgpack.unpackb(result[0])]
|
1214
1198
|
return []
|
1215
1199
|
|
1216
|
-
def set_external_data(self, external_data: dict):
|
1200
|
+
def set_external_data(self, external_data: dict, key: str = "default"):
|
1217
1201
|
"""
|
1218
|
-
Sets the external data for the document.
|
1202
|
+
Sets the external data for the document for a specific key.
|
1219
1203
|
|
1220
1204
|
Args:
|
1221
1205
|
external_data (dict): The external data to store, must be JSON serializable.
|
1206
|
+
key (str): The key to store the data under, defaults to "default"
|
1222
1207
|
"""
|
1223
1208
|
self.__ensure_ed_table_exists()
|
1224
1209
|
serialized_data = sqlite3.Binary(msgpack.packb(external_data))
|
1225
|
-
self.cursor.execute("
|
1210
|
+
self.cursor.execute("DELETE FROM ed WHERE key = ?", [key])
|
1211
|
+
self.cursor.execute("INSERT INTO ed (key, obj) VALUES (?, ?)", [key, serialized_data])
|
1226
1212
|
self.connection.commit()
|
1227
1213
|
|
1228
|
-
def get_external_data(self) -> dict:
|
1214
|
+
def get_external_data(self, key: str = "default") -> dict:
|
1229
1215
|
"""
|
1230
|
-
Gets the external data associated with this document.
|
1216
|
+
Gets the external data associated with this document for a specific key.
|
1217
|
+
|
1218
|
+
Args:
|
1219
|
+
key (str): The key to retrieve data for, defaults to "default"
|
1231
1220
|
|
1232
1221
|
Returns:
|
1233
|
-
dict: The external data stored in the ed table.
|
1222
|
+
dict: The external data stored in the ed table for the given key.
|
1234
1223
|
"""
|
1235
1224
|
self.__ensure_ed_table_exists()
|
1236
|
-
result = self.cursor.execute("SELECT obj FROM ed WHERE
|
1225
|
+
result = self.cursor.execute("SELECT obj FROM ed WHERE key = ?", [key]).fetchone()
|
1237
1226
|
if result and result[0]:
|
1238
1227
|
return msgpack.unpackb(result[0])
|
1239
1228
|
return {}
|
1240
1229
|
|
1230
|
+
def get_external_data_keys(self) -> List[str]:
|
1231
|
+
"""
|
1232
|
+
Gets all keys under which external data is stored.
|
1233
|
+
|
1234
|
+
Returns:
|
1235
|
+
List[str]: A list of all keys that have external data stored.
|
1236
|
+
"""
|
1237
|
+
self.__ensure_ed_table_exists()
|
1238
|
+
results = self.cursor.execute("SELECT key FROM ed").fetchall()
|
1239
|
+
return [row[0] for row in results]
|
1240
|
+
|
1241
|
+
def __ensure_ed_table_exists(self):
|
1242
|
+
"""
|
1243
|
+
Ensure the 'ed' table exists in the database.
|
1244
|
+
Creates the table if it does not exist.
|
1245
|
+
"""
|
1246
|
+
# First check if the old table exists and has id column
|
1247
|
+
old_table = self.cursor.execute("""
|
1248
|
+
SELECT name FROM sqlite_master
|
1249
|
+
WHERE type='table' AND name='ed'
|
1250
|
+
""").fetchone()
|
1251
|
+
|
1252
|
+
if old_table:
|
1253
|
+
# Check if table has id column
|
1254
|
+
table_info = self.cursor.execute("PRAGMA table_info(ed)").fetchall()
|
1255
|
+
has_id_column = any(col[1] == 'id' for col in table_info)
|
1256
|
+
|
1257
|
+
if has_id_column:
|
1258
|
+
# Get the old data and drop the table
|
1259
|
+
data = self.cursor.execute("SELECT obj FROM ed").fetchone()
|
1260
|
+
self.cursor.execute("DROP TABLE ed")
|
1261
|
+
|
1262
|
+
# Create new table with key column
|
1263
|
+
self.cursor.execute("""
|
1264
|
+
CREATE TABLE ed (
|
1265
|
+
key TEXT PRIMARY KEY,
|
1266
|
+
obj BLOB
|
1267
|
+
)
|
1268
|
+
""")
|
1269
|
+
|
1270
|
+
# If there was data in the old table, insert it with default key
|
1271
|
+
if data:
|
1272
|
+
self.cursor.execute("INSERT INTO ed (key, obj) VALUES (?, ?)",
|
1273
|
+
["default", data[0]])
|
1274
|
+
else:
|
1275
|
+
# Table exists but doesn't need migration - do nothing
|
1276
|
+
return
|
1277
|
+
else:
|
1278
|
+
# Create new table if it doesn't exist
|
1279
|
+
self.cursor.execute("""
|
1280
|
+
CREATE TABLE IF NOT EXISTS ed (
|
1281
|
+
key TEXT PRIMARY KEY,
|
1282
|
+
obj BLOB
|
1283
|
+
)
|
1284
|
+
""")
|
1285
|
+
|
1286
|
+
# Check if default key exists, if not insert empty data
|
1287
|
+
result = self.cursor.execute("SELECT COUNT(*) FROM ed WHERE key = 'default'").fetchone()
|
1288
|
+
if result[0] == 0:
|
1289
|
+
self.cursor.execute("INSERT INTO ed (key, obj) VALUES (?, ?)",
|
1290
|
+
["default", sqlite3.Binary(msgpack.packb({}))])
|
1291
|
+
|
1241
1292
|
def __ensure_steps_table_exists(self):
|
1242
1293
|
"""
|
1243
1294
|
Ensure the 'steps' table exists in the database.
|
@@ -1436,22 +1487,31 @@ class PersistenceManager(object):
|
|
1436
1487
|
def get_validations(self) -> list[DocumentTaxonValidation]:
|
1437
1488
|
return self._underlying_persistence.get_validations()
|
1438
1489
|
|
1439
|
-
def get_external_data(self) -> dict:
|
1490
|
+
def get_external_data(self, key="default") -> dict:
|
1440
1491
|
"""
|
1441
1492
|
Gets the external data object associated with this document
|
1442
1493
|
|
1443
1494
|
:return: dict of the external data
|
1444
1495
|
"""
|
1445
|
-
return self._underlying_persistence.get_external_data()
|
1496
|
+
return self._underlying_persistence.get_external_data(key)
|
1497
|
+
|
1498
|
+
def get_external_data_keys(self) -> List[str]:
|
1499
|
+
"""
|
1500
|
+
Gets all keys under which external data is stored.
|
1501
|
+
|
1502
|
+
Returns:
|
1503
|
+
List[str]: A list of all keys that have external data stored.
|
1504
|
+
"""
|
1505
|
+
return self._underlying_persistence.get_external_data_keys()
|
1446
1506
|
|
1447
|
-
def set_external_data(self, external_data:dict):
|
1507
|
+
def set_external_data(self, external_data:dict, key="default"):
|
1448
1508
|
"""
|
1449
1509
|
Sets the external data for this document
|
1450
1510
|
|
1451
1511
|
:param external_data: dict representing the external data, must be JSON serializable
|
1452
1512
|
:return:
|
1453
1513
|
"""
|
1454
|
-
self._underlying_persistence.set_external_data(external_data)
|
1514
|
+
self._underlying_persistence.set_external_data(external_data, key)
|
1455
1515
|
|
1456
1516
|
def get_nodes_by_type(self, node_type: str) -> List[ContentNode]:
|
1457
1517
|
"""
|
@@ -11,9 +11,9 @@ kodexa/model/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
|
|
11
11
|
kodexa/model/entities/check_response.py,sha256=eqBHxO6G2OAziL3p9bHGI-oiPkAG82H6Choc8wyvtM4,3949
|
12
12
|
kodexa/model/entities/product.py,sha256=ZDpHuBE_9FJ-klnkyBvTfPwYOqBkM1wraZMtHqNA8FQ,3526
|
13
13
|
kodexa/model/entities/product_subscription.py,sha256=UcmWR-qgLfdV7VCtJNwzgkanoS8nBSL6ngVuxQUK1M8,3810
|
14
|
-
kodexa/model/model.py,sha256=
|
14
|
+
kodexa/model/model.py,sha256=qh1YUew3UgtjU0t4fAwSXYYuzQjXTOZWZkafyFp_w8M,118801
|
15
15
|
kodexa/model/objects.py,sha256=4Oyjs6omlHfwziAK1m2tFk4jSnzN7lFdXACog07ed1c,185124
|
16
|
-
kodexa/model/persistence.py,sha256=
|
16
|
+
kodexa/model/persistence.py,sha256=ph6SSfyqBLkQoQAMeYNnKLP7tTPmirYRbywkaqa_fF8,72032
|
17
17
|
kodexa/model/utils.py,sha256=6R-3rFiW9irBwj0Mq5yhp7EDXkNUFaeFhr3bWmnlW4g,2961
|
18
18
|
kodexa/pipeline/__init__.py,sha256=sA7f5D6qkdMrpp2xTIeefnrUBI6xxEEWostvxfX_1Cs,236
|
19
19
|
kodexa/pipeline/pipeline.py,sha256=ZYpJAWcwV4YRK589DUhU0vXGQlkNSj4J2TsGbYqTLjo,25221
|
@@ -43,7 +43,7 @@ kodexa/testing/test_utils.py,sha256=v44p__gE7ia67W7WeHN2HBFCWSCUrCZt7G4xBNCmwf8,
|
|
43
43
|
kodexa/training/__init__.py,sha256=xs2L62YpRkIRfslQwtQZ5Yxjhm7sLzX2TrVX6EuBnZQ,52
|
44
44
|
kodexa/training/train_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
45
45
|
kodexa/utils/__init__.py,sha256=Pnim1o9_db5YEnNvDTxpM7HG-qTlL6n8JwFwOafU9wo,5928
|
46
|
-
kodexa-7.
|
47
|
-
kodexa-7.
|
48
|
-
kodexa-7.
|
49
|
-
kodexa-7.
|
46
|
+
kodexa-7.4.412416252968.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
47
|
+
kodexa-7.4.412416252968.dist-info/METADATA,sha256=kCmpaHdD1r67dKPNiNLSPSMW_DLAm_duFEEOiHU22zI,3528
|
48
|
+
kodexa-7.4.412416252968.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
49
|
+
kodexa-7.4.412416252968.dist-info/RECORD,,
|
File without changes
|
File without changes
|