MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / row_key

Function row_key

tests/compliance/diff.py:26–42  ·  view source on GitHub ↗

Build a hashable key from scalar identity fields.

(row, headers)

Source from the content-addressed store, hash-verified

24
25
26def row_key(row, headers):
27 """Build a hashable key from scalar identity fields."""
28 def _hashable(v):
29 if isinstance(v, list):
30 return tuple(sorted(str(x) for x in v))
31 return v
32
33 if isinstance(row, dict):
34 # Use only scalar identity fields for keying (skip list fields like team_uid)
35 id_fields = ['record_uid', 'shared_folder_uid', 'team_uid', 'email', 'vault_owner']
36 parts = tuple(_hashable(row.get(k)) for k in id_fields if k in row and not isinstance(row.get(k), list))
37 if parts:
38 return parts
39 return tuple((k, _hashable(v)) for k, v in sorted(row.items()))
40 if isinstance(row, (list, tuple)):
41 return tuple(_hashable(x) for x in row[:2])
42 return (row,)
43
44
45def _normalize(v):

Callers 1

compare_fileFunction · 0.85

Calls 2

_hashableFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected