diff --git a/ssb.py b/ssb.py index f52339033..0f393044c 100644 --- a/ssb.py +++ b/ssb.py @@ -1,12 +1,11 @@ -__filename__="ssb.py" -__author__="Bob Mottram" -__license__="AGPL3+" -__version__="1.1.0" -__maintainer__="Bob Mottram" -__email__="bob@freedombone.net" -__status__="Production" +__filename__ = "ssb.py" +__author__ = "Bob Mottram" +__license__ = "AGPL3+" +__version__ = "1.1.0" +__maintainer__ = "Bob Mottram" +__email__ = "bob@freedombone.net" +__status__ = "Production" -import json def getSSBAddress(actorJson: {}) -> str: """Returns ssb address for the given actor @@ -22,9 +21,9 @@ def getSSBAddress(actorJson: {}) -> str: continue if not propertyValue.get('value'): continue - if propertyValue['type']!='PropertyValue': + if propertyValue['type'] != 'PropertyValue': continue - propertyValue['value']=propertyValue['value'].strip() + propertyValue['value'] = propertyValue['value'].strip() if not propertyValue['value'].startswith('@'): continue if '=.' not in propertyValue['value']: @@ -38,14 +37,15 @@ def getSSBAddress(actorJson: {}) -> str: return propertyValue['value'] return '' -def setSSBAddress(actorJson: {},ssbAddress: str) -> None: + +def setSSBAddress(actorJson: {}, ssbAddress: str) -> None: """Sets an ssb address for the given actor """ if not actorJson.get('attachment'): - actorJson['attachment']=[] + actorJson['attachment'] = [] # remove any existing value - propertyFound=None + propertyFound = None for propertyValue in actorJson['attachment']: if not propertyValue.get('name'): continue @@ -53,7 +53,7 @@ def setSSBAddress(actorJson: {},ssbAddress: str) -> None: continue if not propertyValue['name'].lower().startswith('ssb'): continue - propertyFound=propertyValue + propertyFound = propertyValue break if propertyFound: actorJson['attachment'].remove(propertyFound) @@ -76,12 +76,12 @@ def setSSBAddress(actorJson: {},ssbAddress: str) -> None: continue if not propertyValue['name'].lower().startswith('ssb'): continue - if propertyValue['type']!='PropertyValue': + if propertyValue['type'] != 'PropertyValue': continue - propertyValue['value']=ssbAddress + propertyValue['value'] = ssbAddress return - newSSBAddress={ + newSSBAddress = { "name": "SSB", "type": "PropertyValue", "value": ssbAddress