tamaki.mes.backup.compare.compareEntityFields
Description
Compares two entities (dictionaries) field by field and identifies which fields were removed, added, or changed:
- Removed: keys present in
oldEntitybut notnewEntity. - Added: keys present in
newEntitybut notoldEntity. - Updated: keys present in both whose values differ (compared with
equalValues).
Raises a TypeError if either argument is not a dictionary.
Syntax
tamaki.mes.backup.compare.compareEntityFields(oldEntity, newEntity)
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
oldEntity | Dict | False | The old state of the entity (field name → value). |
newEntity | Dict | False | The new state of the entity (field name → value). |
Returns
A tuple (removedFields, addedFields, updatedFields) of ResultRow lists, with change types
field remove, field add, and field update respectively.
Code Examples
oldLoc = {"path": "Site/A", "description": "Old", "enabled": True}
newLoc = {"path": "Site/A", "description": "New"}
removed, added, updated = tamaki.mes.backup.compare.compareEntityFields(oldLoc, newLoc)
# removed: [enabled], added: [], updated: [description]