From bc673855875fab8f5f97ac07b191c0b72d8608e8 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 14 Jul 2019 13:10:48 +0100 Subject: [PATCH] Setting skill level to zero removes it --- person.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/person.py b/person.py index 53f94e194..c5accdc06 100644 --- a/person.py +++ b/person.py @@ -88,6 +88,7 @@ def setProfileImage(baseDir: str,httpPrefix :str,nickname: str,domain: str, \ def setSkillLevel(baseDir: str,nickname: str,domain: str, \ skill: str,skillLevelPercent: int) -> bool: """Set a skill level for a person + Setting skill level to zero removes it """ if skillLevelPercent<0 or skillLevelPercent>100: return False @@ -95,12 +96,15 @@ def setSkillLevel(baseDir: str,nickname: str,domain: str, \ if not os.path.isfile(actorFilename): return False with open(actorFilename, 'r') as fp: - actorJson=commentjson.load(fp) - actorJson['skills'][skill]=skillLevelPercent + actorJson=commentjson.load(fp) + if skillLevelPercent>0: + actorJson['skills'][skill]=skillLevelPercent + else: + del actorJson['skills'][skill] with open(actorFilename, 'w') as fp: commentjson.dump(actorJson, fp, indent=4, sort_keys=False) return True - + def createPersonBase(baseDir: str,nickname: str,domain: str,port: int, \ httpPrefix: str, saveToFile: bool,password=None) -> (str,str,{},{}): """Returns the private key, public key, actor and webfinger endpoint