From 5fbc000eea5aff0d4640f8530f7565d8da8d5dc9 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 24 Nov 2020 14:06:42 +0000 Subject: [PATCH] Tidying --- roles.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/roles.py b/roles.py index fe60b2ab3..22db327b3 100644 --- a/roles.py +++ b/roles.py @@ -46,15 +46,20 @@ def clearEditorStatus(baseDir: str) -> None: for f in os.scandir(directory): f = f.name filename = os.fsdecode(f) - if filename.endswith(".json") and '@' in filename: - filename = os.path.join(baseDir + '/accounts/', filename) - if '"editor"' in open(filename).read(): - actorJson = loadJson(filename) - if actorJson: - if actorJson['roles'].get('instance'): - if 'editor' in actorJson['roles']['instance']: - actorJson['roles']['instance'].remove('editor') - saveJson(actorJson, filename) + if '@' not in filename: + continue + if not filename.endswith(".json"): + continue + filename = os.path.join(baseDir + '/accounts/', filename) + if '"editor"' not in open(filename).read(): + continue + actorJson = loadJson(filename) + if not actorJson: + continue + if actorJson['roles'].get('instance'): + if 'editor' in actorJson['roles']['instance']: + actorJson['roles']['instance'].remove('editor') + saveJson(actorJson, filename) def addModerator(baseDir: str, nickname: str, domain: str) -> None: