flake8 format

merge-requests/30/head
Bob Mottram 2020-04-04 12:40:47 +01:00
parent 05d2d3d983
commit a0930a61b8
1 changed files with 17 additions and 17 deletions

34
ssb.py
View File

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