Skip to content

Commit 9d491e3

Browse files
Copilotnomeguy
andcommitted
Format code with black
Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
1 parent 6024706 commit 9d491e3

2 files changed

Lines changed: 85 additions & 86 deletions

File tree

casbin/synced_enforcer.py

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def value(self, value):
3636

3737

3838
class SyncedEnforcer:
39-
4039
"""SyncedEnforcer wraps Enforcer and provides synchronized access.
4140
It's also a drop-in replacement for Enforcer"""
4241

@@ -279,11 +278,11 @@ def add_policy(self, *params):
279278
result = self._e.add_policy(*params)
280279
finally:
281280
self._e.auto_notify_watcher = old_auto_notify
282-
281+
283282
# Notify watcher outside of lock to prevent deadlock
284283
if result and old_auto_notify:
285284
self._notify_watcher("update_for_add_policy", "p", "p", list(params))
286-
285+
287286
return result
288287

289288
def add_named_policy(self, ptype, *params):
@@ -299,11 +298,11 @@ def add_named_policy(self, ptype, *params):
299298
result = self._e.add_named_policy(ptype, *params)
300299
finally:
301300
self._e.auto_notify_watcher = old_auto_notify
302-
301+
303302
# Notify watcher outside of lock to prevent deadlock
304303
if result and old_auto_notify:
305304
self._notify_watcher("update_for_add_policy", "p", ptype, list(params))
306-
305+
307306
return result
308307

309308
def remove_policy(self, *params):
@@ -316,11 +315,11 @@ def remove_policy(self, *params):
316315
result = self._e.remove_policy(*params)
317316
finally:
318317
self._e.auto_notify_watcher = old_auto_notify
319-
318+
320319
# Notify watcher outside of lock to prevent deadlock
321320
if result and old_auto_notify:
322321
self._notify_watcher("update_for_remove_policy", "p", "p", list(params))
323-
322+
324323
return result
325324

326325
def remove_filtered_policy(self, field_index, *field_values):
@@ -333,11 +332,11 @@ def remove_filtered_policy(self, field_index, *field_values):
333332
result = self._e.remove_filtered_policy(field_index, *field_values)
334333
finally:
335334
self._e.auto_notify_watcher = old_auto_notify
336-
335+
337336
# Notify watcher outside of lock to prevent deadlock
338337
if result and old_auto_notify:
339338
self._notify_watcher("update_for_remove_filtered_policy", "p", "p", field_index, *field_values)
340-
339+
341340
return result
342341

343342
def remove_named_policy(self, ptype, *params):
@@ -350,11 +349,11 @@ def remove_named_policy(self, ptype, *params):
350349
result = self._e.remove_named_policy(ptype, *params)
351350
finally:
352351
self._e.auto_notify_watcher = old_auto_notify
353-
352+
354353
# Notify watcher outside of lock to prevent deadlock
355354
if result and old_auto_notify:
356355
self._notify_watcher("update_for_remove_policy", "p", ptype, list(params))
357-
356+
358357
return result
359358

360359
def remove_filtered_named_policy(self, ptype, field_index, *field_values):
@@ -367,11 +366,11 @@ def remove_filtered_named_policy(self, ptype, field_index, *field_values):
367366
result = self._e.remove_filtered_named_policy(ptype, field_index, *field_values)
368367
finally:
369368
self._e.auto_notify_watcher = old_auto_notify
370-
369+
371370
# Notify watcher outside of lock to prevent deadlock
372371
if result and old_auto_notify:
373372
self._notify_watcher("update_for_remove_filtered_policy", "p", ptype, field_index, *field_values)
374-
373+
375374
return result
376375

377376
def has_grouping_policy(self, *params):
@@ -397,11 +396,11 @@ def add_grouping_policy(self, *params):
397396
result = self._e.add_grouping_policy(*params)
398397
finally:
399398
self._e.auto_notify_watcher = old_auto_notify
400-
399+
401400
# Notify watcher outside of lock to prevent deadlock
402401
if result and old_auto_notify:
403402
self._notify_watcher("update_for_add_policy", "g", "g", list(params))
404-
403+
405404
return result
406405

407406
def add_named_grouping_policy(self, ptype, *params):
@@ -417,11 +416,11 @@ def add_named_grouping_policy(self, ptype, *params):
417416
result = self._e.add_named_grouping_policy(ptype, *params)
418417
finally:
419418
self._e.auto_notify_watcher = old_auto_notify
420-
419+
421420
# Notify watcher outside of lock to prevent deadlock
422421
if result and old_auto_notify:
423422
self._notify_watcher("update_for_add_policy", "g", ptype, list(params))
424-
423+
425424
return result
426425

427426
def remove_grouping_policy(self, *params):
@@ -434,11 +433,11 @@ def remove_grouping_policy(self, *params):
434433
result = self._e.remove_grouping_policy(*params)
435434
finally:
436435
self._e.auto_notify_watcher = old_auto_notify
437-
436+
438437
# Notify watcher outside of lock to prevent deadlock
439438
if result and old_auto_notify:
440439
self._notify_watcher("update_for_remove_policy", "g", "g", list(params))
441-
440+
442441
return result
443442

444443
def remove_filtered_grouping_policy(self, field_index, *field_values):
@@ -451,11 +450,11 @@ def remove_filtered_grouping_policy(self, field_index, *field_values):
451450
result = self._e.remove_filtered_grouping_policy(field_index, *field_values)
452451
finally:
453452
self._e.auto_notify_watcher = old_auto_notify
454-
453+
455454
# Notify watcher outside of lock to prevent deadlock
456455
if result and old_auto_notify:
457456
self._notify_watcher("update_for_remove_filtered_policy", "g", "g", field_index, *field_values)
458-
457+
459458
return result
460459

461460
def remove_named_grouping_policy(self, ptype, *params):
@@ -468,11 +467,11 @@ def remove_named_grouping_policy(self, ptype, *params):
468467
result = self._e.remove_named_grouping_policy(ptype, *params)
469468
finally:
470469
self._e.auto_notify_watcher = old_auto_notify
471-
470+
472471
# Notify watcher outside of lock to prevent deadlock
473472
if result and old_auto_notify:
474473
self._notify_watcher("update_for_remove_policy", "g", ptype, list(params))
475-
474+
476475
return result
477476

478477
def remove_filtered_named_grouping_policy(self, ptype, field_index, *field_values):
@@ -485,11 +484,11 @@ def remove_filtered_named_grouping_policy(self, ptype, field_index, *field_value
485484
result = self._e.remove_filtered_named_grouping_policy(ptype, field_index, *field_values)
486485
finally:
487486
self._e.auto_notify_watcher = old_auto_notify
488-
487+
489488
# Notify watcher outside of lock to prevent deadlock
490489
if result and old_auto_notify:
491490
self._notify_watcher("update_for_remove_filtered_policy", "g", ptype, field_index, *field_values)
492-
491+
493492
return result
494493

495494
def add_function(self, name, func):
@@ -765,11 +764,11 @@ def add_policies(self, rules):
765764
result = self._e.add_policies(rules)
766765
finally:
767766
self._e.auto_notify_watcher = old_auto_notify
768-
767+
769768
# Notify watcher outside of lock to prevent deadlock
770769
if result and old_auto_notify:
771770
self._notify_watcher("update_for_add_policies", "p", "p", rules)
772-
771+
773772
return result
774773

775774
def add_policies_ex(self, rules):
@@ -786,11 +785,11 @@ def add_policies_ex(self, rules):
786785
result = self._e.add_policies_ex(rules)
787786
finally:
788787
self._e.auto_notify_watcher = old_auto_notify
789-
788+
790789
# Notify watcher outside of lock to prevent deadlock
791790
if result and old_auto_notify:
792791
self._notify_watcher("update_for_add_policies_ex", "p", "p", rules)
793-
792+
794793
return result
795794

796795
def add_named_policies_ex(self, ptype, rules):
@@ -807,11 +806,11 @@ def add_named_policies_ex(self, ptype, rules):
807806
result = self._e.add_named_policies_ex(ptype, rules)
808807
finally:
809808
self._e.auto_notify_watcher = old_auto_notify
810-
809+
811810
# Notify watcher outside of lock to prevent deadlock
812811
if result and old_auto_notify:
813812
self._notify_watcher("update_for_add_policies_ex", "p", ptype, rules)
814-
813+
815814
return result
816815

817816
def add_named_policies(self, ptype, rules):
@@ -827,11 +826,11 @@ def add_named_policies(self, ptype, rules):
827826
result = self._e.add_named_policies(ptype, rules)
828827
finally:
829828
self._e.auto_notify_watcher = old_auto_notify
830-
829+
831830
# Notify watcher outside of lock to prevent deadlock
832831
if result and old_auto_notify:
833832
self._notify_watcher("update_for_add_policies", "p", ptype, rules)
834-
833+
835834
return result
836835

837836
def remove_policies(self, rules):
@@ -844,11 +843,11 @@ def remove_policies(self, rules):
844843
result = self._e.remove_policies(rules)
845844
finally:
846845
self._e.auto_notify_watcher = old_auto_notify
847-
846+
848847
# Notify watcher outside of lock to prevent deadlock
849848
if result and old_auto_notify:
850849
self._notify_watcher("update_for_remove_policies", "p", "p", rules)
851-
850+
852851
return result
853852

854853
def remove_named_policies(self, ptype, rules):
@@ -861,11 +860,11 @@ def remove_named_policies(self, ptype, rules):
861860
result = self._e.remove_named_policies(ptype, rules)
862861
finally:
863862
self._e.auto_notify_watcher = old_auto_notify
864-
863+
865864
# Notify watcher outside of lock to prevent deadlock
866865
if result and old_auto_notify:
867866
self._notify_watcher("update_for_remove_policies", "p", ptype, rules)
868-
867+
869868
return result
870869

871870
def add_grouping_policies(self, rules):
@@ -882,11 +881,11 @@ def add_grouping_policies(self, rules):
882881
result = self._e.add_grouping_policies(rules)
883882
finally:
884883
self._e.auto_notify_watcher = old_auto_notify
885-
884+
886885
# Notify watcher outside of lock to prevent deadlock
887886
if result and old_auto_notify:
888887
self._notify_watcher("update_for_add_policies", "g", "g", rules)
889-
888+
890889
return result
891890

892891
def add_grouping_policies_ex(self, rules):
@@ -903,11 +902,11 @@ def add_grouping_policies_ex(self, rules):
903902
result = self._e.add_grouping_policies_ex(rules)
904903
finally:
905904
self._e.auto_notify_watcher = old_auto_notify
906-
905+
907906
# Notify watcher outside of lock to prevent deadlock
908907
if result and old_auto_notify:
909908
self._notify_watcher("update_for_add_policies_ex", "g", "g", rules)
910-
909+
911910
return result
912911

913912
def add_named_grouping_policies(self, ptype, rules):
@@ -923,11 +922,11 @@ def add_named_grouping_policies(self, ptype, rules):
923922
result = self._e.add_named_grouping_policies(ptype, rules)
924923
finally:
925924
self._e.auto_notify_watcher = old_auto_notify
926-
925+
927926
# Notify watcher outside of lock to prevent deadlock
928927
if result and old_auto_notify:
929928
self._notify_watcher("update_for_add_policies", "g", ptype, rules)
930-
929+
931930
return result
932931

933932
def add_named_grouping_policies_ex(self, ptype, rules):
@@ -944,11 +943,11 @@ def add_named_grouping_policies_ex(self, ptype, rules):
944943
result = self._e.add_named_grouping_policies_ex(ptype, rules)
945944
finally:
946945
self._e.auto_notify_watcher = old_auto_notify
947-
946+
948947
# Notify watcher outside of lock to prevent deadlock
949948
if result and old_auto_notify:
950949
self._notify_watcher("update_for_add_policies_ex", "g", ptype, rules)
951-
950+
952951
return result
953952

954953
def remove_grouping_policies(self, rules):
@@ -961,11 +960,11 @@ def remove_grouping_policies(self, rules):
961960
result = self._e.remove_grouping_policies(rules)
962961
finally:
963962
self._e.auto_notify_watcher = old_auto_notify
964-
963+
965964
# Notify watcher outside of lock to prevent deadlock
966965
if result and old_auto_notify:
967966
self._notify_watcher("update_for_remove_policies", "g", "g", rules)
968-
967+
969968
return result
970969

971970
def remove_named_grouping_policies(self, ptype, rules):
@@ -978,11 +977,11 @@ def remove_named_grouping_policies(self, ptype, rules):
978977
result = self._e.remove_named_grouping_policies(ptype, rules)
979978
finally:
980979
self._e.auto_notify_watcher = old_auto_notify
981-
980+
982981
# Notify watcher outside of lock to prevent deadlock
983982
if result and old_auto_notify:
984983
self._notify_watcher("update_for_remove_policies", "g", ptype, rules)
985-
984+
986985
return result
987986

988987
def build_incremental_role_links(self, op, ptype, rules):

0 commit comments

Comments
 (0)