File tree Expand file tree Collapse file tree 3 files changed +7
-11
lines changed
jac-cloud/jac_cloud/plugin Expand file tree Collapse file tree 3 files changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -361,7 +361,7 @@ def allow_root(
361
361
if (
362
362
isinstance (anchor , BaseAnchor )
363
363
and (ref_id := root_id .ref_id )
364
- and level != access .anchors .get (ref_id , AccessLevel . NO_ACCESS )
364
+ and level != access .anchors .get (ref_id )
365
365
):
366
366
access .anchors [ref_id ] = level
367
367
anchor ._set .update ({f"access.roots.anchors.{ ref_id } " : level .name })
@@ -456,14 +456,12 @@ def check_access_level(to: Anchor) -> AccessLevel:
456
456
if to_root .access .all > access_level :
457
457
access_level = to_root .access .all
458
458
459
- level = to_root .access .roots .check (jroot .ref_id )
460
- if level > AccessLevel .NO_ACCESS and access_level == AccessLevel .NO_ACCESS :
459
+ if (level := to_root .access .roots .check (jroot .ref_id )) is not None :
461
460
access_level = level
462
461
463
462
# if target anchor have set allowed roots
464
463
# if current root is allowed to target anchor
465
- level = to_access .roots .check (jroot .ref_id )
466
- if level > AccessLevel .NO_ACCESS and access_level == AccessLevel .NO_ACCESS :
464
+ if (level := to_access .roots .check (jroot .ref_id )) is not None :
467
465
access_level = level
468
466
469
467
return access_level
Original file line number Diff line number Diff line change @@ -179,14 +179,12 @@ def check_access_level(to: Anchor) -> AccessLevel:
179
179
if to_root .access .all > access_level :
180
180
access_level = to_root .access .all
181
181
182
- level = to_root .access .roots .check (str (jroot .id ))
183
- if level > AccessLevel .NO_ACCESS and access_level == AccessLevel .NO_ACCESS :
182
+ if (level := to_root .access .roots .check (str (jroot .id ))) is not None :
184
183
access_level = level
185
184
186
185
# if target anchor have set allowed roots
187
186
# if current root is allowed to target anchor
188
- level = to_access .roots .check (str (jroot .id ))
189
- if level > AccessLevel .NO_ACCESS and access_level == AccessLevel .NO_ACCESS :
187
+ if (level := to_access .roots .check (str (jroot .id ))) is not None :
190
188
access_level = level
191
189
192
190
return access_level
Original file line number Diff line number Diff line change @@ -44,9 +44,9 @@ class Access:
44
44
45
45
anchors : dict [str , AccessLevel ] = field (default_factory = dict )
46
46
47
- def check (self , anchor : str ) -> AccessLevel :
47
+ def check (self , anchor : str ) -> AccessLevel | None :
48
48
"""Validate access."""
49
- return self .anchors .get (anchor , AccessLevel . NO_ACCESS )
49
+ return self .anchors .get (anchor )
50
50
51
51
52
52
@dataclass
You can’t perform that action at this time.
0 commit comments