forked from indymedia/epicyon
flake8 format
parent
a85baf08ed
commit
e2e2db91d4
32
matrix.py
32
matrix.py
|
@ -1,12 +1,11 @@
|
||||||
__filename__="matrix.py"
|
__filename__ = "matrix.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 getMatrixAddress(actorJson: {}) -> str:
|
def getMatrixAddress(actorJson: {}) -> str:
|
||||||
"""Returns matrix address for the given actor
|
"""Returns matrix address for the given actor
|
||||||
|
@ -22,7 +21,7 @@ def getMatrixAddress(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
|
||||||
|
@ -35,14 +34,15 @@ def getMatrixAddress(actorJson: {}) -> str:
|
||||||
return propertyValue['value']
|
return propertyValue['value']
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def setMatrixAddress(actorJson: {},matrixAddress: str) -> None:
|
|
||||||
|
def setMatrixAddress(actorJson: {}, matrixAddress: str) -> None:
|
||||||
"""Sets an matrix address for the given actor
|
"""Sets an matrix 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
|
||||||
|
@ -50,7 +50,7 @@ def setMatrixAddress(actorJson: {},matrixAddress: str) -> None:
|
||||||
continue
|
continue
|
||||||
if not propertyValue['name'].lower().startswith('matrix'):
|
if not propertyValue['name'].lower().startswith('matrix'):
|
||||||
continue
|
continue
|
||||||
propertyFound=propertyValue
|
propertyFound = propertyValue
|
||||||
break
|
break
|
||||||
if propertyFound:
|
if propertyFound:
|
||||||
actorJson['attachment'].remove(propertyFound)
|
actorJson['attachment'].remove(propertyFound)
|
||||||
|
@ -73,12 +73,12 @@ def setMatrixAddress(actorJson: {},matrixAddress: str) -> None:
|
||||||
continue
|
continue
|
||||||
if not propertyValue['name'].lower().startswith('matrix'):
|
if not propertyValue['name'].lower().startswith('matrix'):
|
||||||
continue
|
continue
|
||||||
if propertyValue['type']!='PropertyValue':
|
if propertyValue['type'] != 'PropertyValue':
|
||||||
continue
|
continue
|
||||||
propertyValue['value']=matrixAddress
|
propertyValue['value'] = matrixAddress
|
||||||
return
|
return
|
||||||
|
|
||||||
newMatrixAddress={
|
newMatrixAddress = {
|
||||||
"name": "Matrix",
|
"name": "Matrix",
|
||||||
"type": "PropertyValue",
|
"type": "PropertyValue",
|
||||||
"value": matrixAddress
|
"value": matrixAddress
|
||||||
|
|
Loading…
Reference in New Issue