Skip to content

Commit 4c99900

Browse files
committed
Updates to README.md - backquotes, py syntax coloring, etc
1 parent d1d5a2f commit 4c99900

1 file changed

Lines changed: 25 additions & 14 deletions

File tree

README.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2122,40 +2122,51 @@ Atomic ACLs
21222122
-----------
21232123

21242124
A list of permissions may be added to an object atomically using
2125-
the AccessManager's apply_atomic_operations method:
2126-
```
2125+
the AccessManager's `apply_atomic_operations` method:
2126+
```py
21272127
from irods.access import ACLOperation
21282128
from irods.helpers import home_collection
21292129
session = irods.helpers.make_session()
21302130
myCollection = session.collections.create(f"{home_collection(session).path}/newCollection")
21312131

2132-
session.acls.apply_atomic_operations(myCollection.path,
2133-
*[ACLOperation("read", "public"),
2134-
ACLOperation("write", "bob", "otherZone")
2135-
])
2132+
session.acls.apply_atomic_operations(
2133+
myCollection.path,
2134+
*[
2135+
ACLOperation("read", "public"),
2136+
ACLOperation("write", "bob", "otherZone")
2137+
]
2138+
)
21362139
```
2137-
ACLOperation objects form a linear order with iRODSAccess objects, and
2140+
`ACLOperation` objects form a linear order with `iRODSAccess` objects, and
21382141
indeed are subclassed from them as well, allowing equivalency testing.
21392142

21402143
Thus, for example:
2141-
```
2144+
```py
21422145
ACLOperation('read','public') in sess.acls.get(object)
21432146
```
21442147
is a valid operation, so that an application that tends to cache object
21452148
permissions client-side might use such checks in optimizing atomic ACL
2146-
requests against the inclusion of any redundant ACLOperations.
2149+
requests against the inclusion of any redundant ACL operations.
21472150

21482151
For purposes of sorting, a `__lt__` operator is also defined that would
2149-
allow sorting of lists of iRODSAccess, ACLOperations, or the two intermixed:
2150-
```
2151-
perms_list=[ACLOperation('read','bob'), iRODSAccess('read','/tempZone/home/alice','alice'), ]
2152+
allow sorting of lists of `iRODSAccess`, `ACLOperations`, or the two intermixed:
2153+
```py
2154+
perms_list=[
2155+
ACLOperation('read', 'bob'),
2156+
iRODSAccess('read', '/tempZone/home/alice', 'alice')
2157+
]
21522158
print(sorted(perms_list))
21532159
```
21542160

21552161
and, as always, a sort key may be used for custom sorting; for example,
21562162
the following sorts the objects simply by ascending numerical value of the access:
2157-
```
2158-
perms = sorted([ACLOperation('read','bob'), ACLOperation('write', 'rods'), ACLOperation('read_object','alice')],
2163+
```py
2164+
perms = sorted(
2165+
[
2166+
ACLOperation('read', 'bob'),
2167+
ACLOperation('write', 'rods'),
2168+
ACLOperation('read_object', 'alice')
2169+
],
21592170
key=lambda acl: iRODSAccess.codes[acl.access_name]
21602171
)
21612172
```

0 commit comments

Comments
 (0)