@@ -2149,15 +2149,19 @@ The following code sorts the objects based on their lexical order starting with
21492149normalized `access_name` , which serves to group identical permissions together:
21502150```py
21512151from irods.access import *
2152- normalize = lambda acl : acl.copy( decanonicalize = - 1 , implied_zone = ' tempZone ' )
2152+ import irods.helpers
21532153acls = [
21542154 iRODSAccess(' read_object' , ' /tempZone/home/alice' , ' bob' , ' tempZone' ),
21552155 ACLOperation(' write' , ' rods' ),
21562156 ACLOperation(' read' , ' bob' ),
21572157]
2158+
2159+ session = irods.helpers.make_session()
2160+ normalize = lambda acl : acl.normal(session)
2161+
21582162print (normalize(acls[0 ]) == normalize(acls[2 ]))
21592163acls.sort(key = normalize)
2160- print (normalize(iRODSAccess(' read' , ' /tempZone/home/alice ' , ' bob' )) in map (normalize, acls))
2164+ print (normalize(iRODSAccess(' read' , ' ' , ' bob' )) in map (normalize,acls))
21612165```
21622166
21632167If strict order of permissions is desired, we can use code such as the following:
@@ -2166,11 +2170,11 @@ from irods.access import *
21662170from pprint import pp
21672171pp(sorted (
21682172 [
2169- ACLOperation(' read' , ' bob' ),
2173+ ACLOperation(' read' , ' bob' ),
21702174 ACLOperation(' own' , ' rods' ),
21712175 ACLOperation(' read_object' , ' alice' )
21722176 ],
2173- key = lambda acl : (all_permissions[acl.access_name], normalize( acl))
2177+ key = lambda acl : (all_permissions[acl.access_name], acl.normal( ))
21742178))
21752179```
21762180
0 commit comments