mirror of https://gitlab.com/bashrc2/epicyon
flake8 format
parent
ad2c26eebf
commit
6d19fa47a1
42
tox.py
42
tox.py
|
@ -1,12 +1,11 @@
|
||||||
__filename__="tox.py"
|
__filename__ = "tox.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 getToxAddress(actorJson: {}) -> str:
|
def getToxAddress(actorJson: {}) -> str:
|
||||||
"""Returns tox address for the given actor
|
"""Returns tox address for the given actor
|
||||||
|
@ -22,12 +21,12 @@ def getToxAddress(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 len(propertyValue['value'])!=76:
|
if len(propertyValue['value']) != 76:
|
||||||
continue
|
continue
|
||||||
if propertyValue['value'].upper()!=propertyValue['value']:
|
if propertyValue['value'].upper() != propertyValue['value']:
|
||||||
continue
|
continue
|
||||||
if '"' in propertyValue['value']:
|
if '"' in propertyValue['value']:
|
||||||
continue
|
continue
|
||||||
|
@ -40,14 +39,15 @@ def getToxAddress(actorJson: {}) -> str:
|
||||||
return propertyValue['value']
|
return propertyValue['value']
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def setToxAddress(actorJson: {},toxAddress: str) -> None:
|
|
||||||
|
def setToxAddress(actorJson: {}, toxAddress: str) -> None:
|
||||||
"""Sets an tox address for the given actor
|
"""Sets an tox 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
|
||||||
|
@ -55,14 +55,14 @@ def setToxAddress(actorJson: {},toxAddress: str) -> None:
|
||||||
continue
|
continue
|
||||||
if not propertyValue['name'].lower().startswith('tox'):
|
if not propertyValue['name'].lower().startswith('tox'):
|
||||||
continue
|
continue
|
||||||
propertyFound=propertyValue
|
propertyFound = propertyValue
|
||||||
break
|
break
|
||||||
if propertyFound:
|
if propertyFound:
|
||||||
actorJson['attachment'].remove(propertyFound)
|
actorJson['attachment'].remove(propertyFound)
|
||||||
|
|
||||||
if len(toxAddress)!=76:
|
if len(toxAddress) != 76:
|
||||||
return
|
return
|
||||||
if toxAddress.upper()!=toxAddress:
|
if toxAddress.upper() != toxAddress:
|
||||||
return
|
return
|
||||||
if '"' in toxAddress:
|
if '"' in toxAddress:
|
||||||
return
|
return
|
||||||
|
@ -80,12 +80,12 @@ def setToxAddress(actorJson: {},toxAddress: str) -> None:
|
||||||
continue
|
continue
|
||||||
if not propertyValue['name'].lower().startswith('tox'):
|
if not propertyValue['name'].lower().startswith('tox'):
|
||||||
continue
|
continue
|
||||||
if propertyValue['type']!='PropertyValue':
|
if propertyValue['type'] != 'PropertyValue':
|
||||||
continue
|
continue
|
||||||
propertyValue['value']=toxAddress
|
propertyValue['value'] = toxAddress
|
||||||
return
|
return
|
||||||
|
|
||||||
newToxAddress={
|
newToxAddress = {
|
||||||
"name": "Tox",
|
"name": "Tox",
|
||||||
"type": "PropertyValue",
|
"type": "PropertyValue",
|
||||||
"value": toxAddress
|
"value": toxAddress
|
||||||
|
|
Loading…
Reference in New Issue