flake8 format

main
Bob Mottram 2020-04-03 19:52:18 +01:00
parent 7d47d27dec
commit 97b0338441
1 changed files with 26 additions and 24 deletions

50
pgp.py
View File

@ -1,12 +1,11 @@
__filename__="pgp.py" __filename__ = "pgp.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 getEmailAddress(actorJson: {}) -> str: def getEmailAddress(actorJson: {}) -> str:
"""Returns the email address for the given actor """Returns the email address for the given actor
@ -22,7 +21,7 @@ def getEmailAddress(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
if '@' not in propertyValue['value']: if '@' not in propertyValue['value']:
continue continue
@ -31,6 +30,7 @@ def getEmailAddress(actorJson: {}) -> str:
return propertyValue['value'] return propertyValue['value']
return '' return ''
def getPGPpubKey(actorJson: {}) -> str: def getPGPpubKey(actorJson: {}) -> str:
"""Returns PGP public key for the given actor """Returns PGP public key for the given actor
""" """
@ -45,21 +45,22 @@ def getPGPpubKey(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
if '--BEGIN PGP PUBLIC KEY' not in propertyValue['value']: if '--BEGIN PGP PUBLIC KEY' not in propertyValue['value']:
continue continue
return propertyValue['value'] return propertyValue['value']
return '' return ''
def setEmailAddress(actorJson: {},emailAddress: str) -> None:
def setEmailAddress(actorJson: {}, emailAddress: str) -> None:
"""Sets the email address for the given actor """Sets the email 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
@ -67,7 +68,7 @@ def setEmailAddress(actorJson: {},emailAddress: str) -> None:
continue continue
if not propertyValue['name'].lower().startswith('email'): if not propertyValue['name'].lower().startswith('email'):
continue continue
propertyFound=propertyValue propertyFound = propertyValue
break break
if propertyFound: if propertyFound:
actorJson['attachment'].remove(propertyFound) actorJson['attachment'].remove(propertyFound)
@ -86,26 +87,27 @@ def setEmailAddress(actorJson: {},emailAddress: str) -> None:
continue continue
if not propertyValue['name'].lower().startswith('email'): if not propertyValue['name'].lower().startswith('email'):
continue continue
if propertyValue['type']!='PropertyValue': if propertyValue['type'] != 'PropertyValue':
continue continue
propertyValue['value']=emailAddress propertyValue['value'] = emailAddress
return return
newEmailAddress={ newEmailAddress = {
"name": "Email", "name": "Email",
"type": "PropertyValue", "type": "PropertyValue",
"value": emailAddress "value": emailAddress
} }
actorJson['attachment'].append(newEmailAddress) actorJson['attachment'].append(newEmailAddress)
def setPGPpubKey(actorJson: {},PGPpubKey: str) -> None:
def setPGPpubKey(actorJson: {}, PGPpubKey: str) -> None:
"""Sets a PGP public key for the given actor """Sets a PGP public key 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
@ -113,7 +115,7 @@ def setPGPpubKey(actorJson: {},PGPpubKey: str) -> None:
continue continue
if not propertyValue['name'].lower().startswith('pgp'): if not propertyValue['name'].lower().startswith('pgp'):
continue continue
propertyFound=propertyValue propertyFound = propertyValue
break break
if propertyFound: if propertyFound:
actorJson['attachment'].remove(propertyValue) actorJson['attachment'].remove(propertyValue)
@ -128,12 +130,12 @@ def setPGPpubKey(actorJson: {},PGPpubKey: str) -> None:
continue continue
if not propertyValue['name'].lower().startswith('pgp'): if not propertyValue['name'].lower().startswith('pgp'):
continue continue
if propertyValue['type']!='PropertyValue': if propertyValue['type'] != 'PropertyValue':
continue continue
propertyValue['value']=PGPpubKey propertyValue['value'] = PGPpubKey
return return
newPGPpubKey={ newPGPpubKey = {
"name": "PGP", "name": "PGP",
"type": "PropertyValue", "type": "PropertyValue",
"value": PGPpubKey "value": PGPpubKey