Skip to content

Commit a0dfe16

Browse files
committed
rename normal->normalize
1 parent 789f4cb commit a0dfe16

3 files changed

Lines changed: 14 additions & 16 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,11 +2157,11 @@ acls = [
21572157
]
21582158

21592159
session = irods.helpers.make_session()
2160-
normalize = lambda acl: acl.normal(local_zone=session.zone)
2160+
N = lambda acl: acl.normalize(local_zone=session.zone)
21612161

2162-
print(normalize(acls[0]) == normalize(acls[2]))
2163-
acls.sort(key=normalize)
2164-
print(normalize(iRODSAccess('read', '', 'bob')) in map(normalize,acls))
2162+
print(N(acls[0]) == N(acls[2]))
2163+
acls.sort(key=N)
2164+
print( N(iRODSAccess('read', '', 'bob')) in map(N, acls) )
21652165
```
21662166

21672167
If strict order of permissions is desired, we can use code such as the following:
@@ -2174,7 +2174,7 @@ pp(sorted(
21742174
ACLOperation('own', 'rods'),
21752175
ACLOperation('read_object', 'alice')
21762176
],
2177-
key=lambda acl: (all_permissions[acl.access_name], acl.normal())
2177+
key=lambda acl: (all_permissions[acl.access_name], acl.normalize())
21782178
))
21792179
```
21802180

irods/access.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def __eq__(self, other):
119119
def __hash__(self):
120120
return hash((self.access_name, str(self.path), self.user_name, self.user_zone))
121121

122-
def normal(self, local_zone=""):
122+
def normalize(self, local_zone=""):
123123
"""
124124
Create a normalized version of the object for comparison in sorting or determining equivalence.
125125
@@ -132,9 +132,9 @@ def normal(self, local_zone=""):
132132
The normalized copy of the source object. In practice, this will be an ACLOperation or iRODSAccess
133133
object, according to the type of the source object.
134134
"""
135-
normal_form = self.copy(decanonicalize=-1, implied_zone=local_zone)
136-
normal_form.path = ""
137-
return normal_form
135+
normalized_form = self.copy(decanonicalize=-1, implied_zone=local_zone)
136+
normalized_form.path = ""
137+
return normalized_form
138138

139139
def copy(self, decanonicalize=False, implied_zone=''):
140140
"""

irods/test/access_test.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -514,13 +514,11 @@ def test_atomic_acls__issue_505(self):
514514
a4 := ACLOperation("read", group.name),
515515
)
516516

517-
accesses = {acl.normal(ses.zone) for acl in ses.acls.get(self.coll)}
518-
519-
# Assert that the ACLs we added are among those listed for the object in the catalog.
520-
self.assertIn(a1.normal(ses.zone), accesses)
521-
self.assertIn(a2.normal(ses.zone), accesses)
522-
self.assertIn(a3.normal(ses.zone), accesses)
523-
self.assertIn(a4.normal(ses.zone), accesses)
517+
# Assert that the ACLs we added are now a subset of those now listed in the catalog.
518+
self.assertLessEqual(
519+
{acl.normalize(ses.zone) for acl in (a1,a2,a3,a4)},
520+
{acl.normalize(ses.zone) for acl in ses.acls.get(self.coll)}
521+
)
524522

525523
finally:
526524
if user1:

0 commit comments

Comments
 (0)