Skip to content

Commit 32f6a24

Browse files
committed
ruff related changes
1 parent 1b2e7e1 commit 32f6a24

3 files changed

Lines changed: 49 additions & 45 deletions

File tree

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,10 +2141,9 @@ Thus, for example:
21412141
```
21422142
ACLOperation('read','public') in sess.acls.get(object)
21432143
```
2144-
is a valid operation. Consequently, any client application that habitually
2145-
caches object permissions could use similar code to check new ACLOperations against the cache
2146-
and conceivably be able to optimize size of an atomic ACLs request by eliminating
2147-
any ACLOperations that might have been redundant.
2144+
is a valid operation, so that an application that tends to cache object
2145+
permissions client-side might use such checks in optimizing atomic ACL
2146+
requests against the inclusion of any redundant ACLOperations.
21482147

21492148
Quotas (v2.0.0)
21502149
---------------

irods/access.py

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,42 @@ class _Access_LookupMeta(type):
2626
@staticmethod
2727
def _codes():
2828
return collections.OrderedDict(
29-
(key_, value_)
30-
for key_, value_ in sorted(
31-
dict(
32-
# copied from iRODS source code in
33-
# ./server/core/include/irods/catalog_utilities.hpp:
34-
null=1000,
35-
execute=1010,
36-
read_annotation=1020,
37-
read_system_metadata=1030,
38-
read_metadata=1040,
39-
read_object=1050,
40-
write_annotation=1060,
41-
create_metadata=1070,
42-
modify_metadata=1080,
43-
delete_metadata=1090,
44-
administer_object=1100,
45-
create_object=1110,
46-
modify_object=1120,
47-
delete_object=1130,
48-
create_token=1140,
49-
delete_token=1150,
50-
curate=1160,
51-
own=1200,
52-
).items(),
53-
key=lambda _: _[1],
29+
(key_, value_)
30+
for key_, value_ in sorted(
31+
dict(
32+
# copied from iRODS source code in
33+
# ./server/core/include/irods/catalog_utilities.hpp:
34+
null=1000,
35+
execute=1010,
36+
read_annotation=1020,
37+
read_system_metadata=1030,
38+
read_metadata=1040,
39+
read_object=1050,
40+
write_annotation=1060,
41+
create_metadata=1070,
42+
modify_metadata=1080,
43+
delete_metadata=1090,
44+
administer_object=1100,
45+
create_object=1110,
46+
modify_object=1120,
47+
delete_object=1130,
48+
create_token=1140,
49+
delete_token=1150,
50+
curate=1160,
51+
own=1200,
52+
).items(),
53+
key=lambda _: _[1],
54+
)
55+
if key_ in _ichmod_listed_permissions
5456
)
55-
if key_ in _ichmod_listed_permissions
56-
)
5757

5858
@property
59-
def codes(metaclass_target): return metaclass_target._codes()
59+
def codes(metaclass_target):
60+
return metaclass_target._codes()
6061

6162
@property
6263
def strings(metaclass_target):
63-
return collections.OrderedDict((number, string) for string, number in
64-
metaclass_target._codes().items())
64+
return collections.OrderedDict((number, string) for string, number in metaclass_target._codes().items())
6565

6666
def __getitem__(self, key):
6767
return self.codes[key]
@@ -76,7 +76,7 @@ def items(self):
7676
return list(zip(self.keys(), self.values()))
7777

7878

79-
class iRODSAccess(metaclass=_Access_LookupMeta):
79+
class _iRODSAccess_base:
8080
@classmethod
8181
def to_int(cls, key):
8282
return cls.codes[key]
@@ -85,10 +85,7 @@ def to_int(cls, key):
8585
def to_string(cls, key):
8686
return cls.strings[key]
8787

88-
89-
def __init__(self, access_name, path, user_name="", user_zone="", user_type=None):
90-
self.codes = self.__class__.codes.copy()
91-
self.strings = self.__class__.strings.copy()
88+
def __init__(self, access_name, path, user_name, user_zone, user_type):
9289
self.access_name = access_name
9390
if isinstance(path, (iRODSCollection, iRODSDataObject)):
9491
self.path = path.path
@@ -148,6 +145,13 @@ def __repr__(self):
148145
return f"<iRODSAccess {access_name} {self.path} {self.user_name}{user_type_hint} {self.user_zone}>"
149146

150147

148+
class iRODSAccess(_iRODSAccess_base, metaclass=_Access_LookupMeta):
149+
def __init__(self, access_name, path, user_name="", user_zone="", user_type=None):
150+
self.codes = self.__class__.codes
151+
self.strings = self.__class__.strings
152+
super().__init__(access_name, path, user_name, user_zone, user_type)
153+
154+
151155
class ACLOperation(iRODSAccess):
152156
def __init__(self, access_name: str, user_name: str = "", user_zone: str = ""):
153157
super().__init__(
@@ -198,7 +202,7 @@ def __repr__(self):
198202
}
199203

200204

201-
class _iRODSAccess_pre_4_3_0(iRODSAccess):
205+
class _iRODSAccess_pre_4_3_0(_iRODSAccess_base):
202206
codes = collections.OrderedDict(
203207
(key.replace("_", " "), value)
204208
for key, value in iRODSAccess.codes.items()

irods/test/access_test.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -508,13 +508,14 @@ def test_atomic_acls_505(self):
508508
group = ses.groups.create("test_group_505")
509509
ses.acls.apply_atomic_operations(
510510
self.coll_path,
511-
a1:=ACLOperation("write", user1.name, user1.zone),
512-
a2:=ACLOperation("read", user2.name, user2.zone),
513-
a3:=ACLOperation("read", user3.name),
514-
a4:=ACLOperation("read", group.name),
511+
a1 := ACLOperation("write", user1.name, user1.zone),
512+
a2 := ACLOperation("read", user2.name, user2.zone),
513+
a3 := ACLOperation("read", user3.name),
514+
a4 := ACLOperation("read", group.name),
515515
)
516516

517-
normalize = lambda access: access.copy(decanonicalize=True, implied_zone=ses.zone)
517+
def normalize(access):
518+
return access.copy(decanonicalize=True, implied_zone=ses.zone)
518519

519520
accesses = [normalize(acl) for acl in ses.acls.get(self.coll)]
520521

0 commit comments

Comments
 (0)