Snake case

merge-requests/30/head
Bob Mottram 2022-01-03 21:19:01 +00:00
parent d728148709
commit 4b72dfcb30
1 changed files with 14 additions and 14 deletions

28
xmpp.py
View File

@ -16,9 +16,9 @@ def get_xmpp_address(actor_json: {}) -> str:
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): if not property_value.get('name'):
continue continue
nameLower = property_value['name'].lower() name_lower = property_value['name'].lower()
if not (nameLower.startswith('xmpp') or if not (name_lower.startswith('xmpp') or
nameLower.startswith('jabber')): name_lower.startswith('jabber')):
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
@ -37,15 +37,15 @@ def get_xmpp_address(actor_json: {}) -> str:
def set_xmpp_address(actor_json: {}, xmpp_address: str) -> None: def set_xmpp_address(actor_json: {}, xmpp_address: str) -> None:
"""Sets an xmpp address for the given actor """Sets an xmpp address for the given actor
""" """
notXmppAddress = False not_xmpp_address = False
if '@' not in xmpp_address: if '@' not in xmpp_address:
notXmppAddress = True not_xmpp_address = True
if '.' not in xmpp_address: if '.' not in xmpp_address:
notXmppAddress = True not_xmpp_address = True
if '"' in xmpp_address: if '"' in xmpp_address:
notXmppAddress = True not_xmpp_address = True
if '<' in xmpp_address: if '<' in xmpp_address:
notXmppAddress = True not_xmpp_address = True
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
actor_json['attachment'] = [] actor_json['attachment'] = []
@ -64,7 +64,7 @@ def set_xmpp_address(actor_json: {}, xmpp_address: str) -> None:
break break
if property_found: if property_found:
actor_json['attachment'].remove(property_found) actor_json['attachment'].remove(property_found)
if notXmppAddress: if not_xmpp_address:
return return
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
@ -72,18 +72,18 @@ def set_xmpp_address(actor_json: {}, xmpp_address: str) -> None:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
nameLower = property_value['name'].lower() name_lower = property_value['name'].lower()
if not (nameLower.startswith('xmpp') or if not (name_lower.startswith('xmpp') or
nameLower.startswith('jabber')): name_lower.startswith('jabber')):
continue continue
if property_value['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
property_value['value'] = xmpp_address property_value['value'] = xmpp_address
return return
newXmppAddress = { new_xmpp_address = {
"name": "XMPP", "name": "XMPP",
"type": "PropertyValue", "type": "PropertyValue",
"value": xmpp_address "value": xmpp_address
} }
actor_json['attachment'].append(newXmppAddress) actor_json['attachment'].append(new_xmpp_address)