tamaki.mes.backup.compare.genericCompareEntities
Description
Compares two lists of entities of the same entityType. Entities are matched by their key fields
(looked up with getKeyFields and keyed with getKey). Entities
present in only one list are reported as added or removed; for entities present in both lists, their
fields are compared with compareEntityFields and each differing field
becomes an updated ResultRow tagged with the entity type and its key fields.
Raises a TypeError if the list/type arguments are the wrong type, or a ValueError if entityType
is not recognised.
Syntax
tamaki.mes.backup.compare.genericCompareEntities(oldEntityList, newEntityList, entityType)
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
oldEntityList | List | False | The list of entity dictionaries in the old state. |
newEntityList | List | False | The list of entity dictionaries in the new state. |
entityType | String | False | The entity type being compared (for example locations, materials). |
Returns
A tuple (removedEntities, addedEntities, updatedEntities) of ResultRow lists:
| Element | Description |
|---|---|
removedEntities | Entities present only in the old list (changeType entity remove). |
addedEntities | Entities present only in the new list (changeType entity add). |
updatedEntities | Field-level changes for entities present in both lists, each carrying the entity type and key fields. |
Code Examples
oldLocations = oldData["locations"]
newLocations = newData["locations"]
removed, added, updated = tamaki.mes.backup.compare.genericCompareEntities(oldLocations, newLocations, "locations")