From bb12ce191e714983728d5672321fd3a42e6d43d9 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 4 Apr 2020 15:17:48 +0100 Subject: [PATCH] flake8 format --- xmpp.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/xmpp.py b/xmpp.py index 2fa26984..58dd6a99 100644 --- a/xmpp.py +++ b/xmpp.py @@ -1,12 +1,11 @@ -__filename__="xmpp.py" -__author__="Bob Mottram" -__license__="AGPL3+" -__version__="1.1.0" -__maintainer__="Bob Mottram" -__email__="bob@freedombone.net" -__status__="Production" +__filename__ = "xmpp.py" +__author__ = "Bob Mottram" +__license__ = "AGPL3+" +__version__ = "1.1.0" +__maintainer__ = "Bob Mottram" +__email__ = "bob@freedombone.net" +__status__ = "Production" -import json def getXmppAddress(actorJson: {}) -> str: """Returns xmpp address for the given actor @@ -16,15 +15,15 @@ def getXmppAddress(actorJson: {}) -> str: for propertyValue in actorJson['attachment']: if not propertyValue.get('name'): continue - nameLower=propertyValue['name'].lower() - if not (nameLower.startswith('xmpp') or \ + nameLower = propertyValue['name'].lower() + if not (nameLower.startswith('xmpp') or nameLower.startswith('jabber')): continue if not propertyValue.get('type'): continue if not propertyValue.get('value'): continue - if propertyValue['type']!='PropertyValue': + if propertyValue['type'] != 'PropertyValue': continue if '@' not in propertyValue['value']: continue @@ -33,23 +32,24 @@ def getXmppAddress(actorJson: {}) -> str: return propertyValue['value'] return '' -def setXmppAddress(actorJson: {},xmppAddress: str) -> None: + +def setXmppAddress(actorJson: {}, xmppAddress: str) -> None: """Sets an xmpp 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 if not propertyValue.get('type'): continue - if not (propertyValue['name'].lower().startswith('xmpp') or \ + if not (propertyValue['name'].lower().startswith('xmpp') or propertyValue['name'].lower().startswith('jabber')): continue - propertyFound=propertyValue + propertyFound = propertyValue break if propertyFound: actorJson['attachment'].remove(propertyFound) @@ -66,16 +66,16 @@ def setXmppAddress(actorJson: {},xmppAddress: str) -> None: continue if not propertyValue.get('type'): continue - nameLower=propertyValue['name'].lower() - if not (nameLower.startswith('xmpp') or \ + nameLower = propertyValue['name'].lower() + if not (nameLower.startswith('xmpp') or nameLower.startswith('jabber')): continue - if propertyValue['type']!='PropertyValue': + if propertyValue['type'] != 'PropertyValue': continue - propertyValue['value']=xmppAddress + propertyValue['value'] = xmppAddress return - newXmppAddress={ + newXmppAddress = { "name": "XMPP", "type": "PropertyValue", "value": xmppAddress