Skip to content

Commit 5b1c514

Browse files
committed
README example for normalization before comparison of acl-like objects
1 parent 8397b34 commit 5b1c514

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2138,7 +2138,21 @@ session.acls.apply_atomic_operations(
21382138
)
21392139
```
21402140
`ACLOperation` objects form a linear order with `iRODSAccess` objects, and
2141-
indeed are subclassed from them as well, allowing equivalency testing.
2141+
indeed are subclassed from them as well, allowing intermixed sequences to be
2142+
sorted; however, care should be taken to normalize the objects before comparisons
2143+
or for related uses of the 'in' operator:
2144+
```py
2145+
normalize = lambda acl: acl.copy(decanonicalize=True, implied_zone='tempZone')
2146+
acls = sorted(
2147+
[
2148+
iRODSAccess('read object', '/tempZone/home/alice', 'bob', 'tempZone'),
2149+
ACLOperation('write', 'rods'),
2150+
ACLOperation('read', 'bob'),
2151+
],
2152+
key=normalize
2153+
)
2154+
print(normalize(acls[0]) == normalize(acls[1]))
2155+
```
21422156

21432157
Thus, for example:
21442158
```py

0 commit comments

Comments
 (0)