Snake case

merge-requests/26/head
Bob Mottram 2022-01-02 12:40:33 +00:00
parent ca4931daa4
commit 7b95d3c3a2
1 changed files with 12 additions and 12 deletions

View File

@ -28,18 +28,18 @@ def get_enigma_pub_key(actor_json: {}) -> str:
return '' return ''
def set_enigma_pub_key(actor_json: {}, enigmaPubKey: str) -> None: def set_enigma_pub_key(actor_json: {}, enigma_pub_key: str) -> None:
"""Sets a Enigma public key for the given actor """Sets a Enigma public key for the given actor
""" """
removeKey = False remove_key = False
if not enigmaPubKey: if not enigma_pub_key:
removeKey = True remove_key = True
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
actor_json['attachment'] = [] actor_json['attachment'] = []
# remove any existing value # remove any existing value
propertyFound = None property_found = None
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
@ -47,11 +47,11 @@ def set_enigma_pub_key(actor_json: {}, enigmaPubKey: str) -> None:
continue continue
if not property_value['name'].lower().startswith('enigma'): if not property_value['name'].lower().startswith('enigma'):
continue continue
propertyFound = property_value property_found = property_value
break break
if propertyFound: if property_found:
actor_json['attachment'].remove(property_value) actor_json['attachment'].remove(property_value)
if removeKey: if remove_key:
return return
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
@ -63,12 +63,12 @@ def set_enigma_pub_key(actor_json: {}, enigmaPubKey: str) -> None:
continue continue
if property_value['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
property_value['value'] = enigmaPubKey property_value['value'] = enigma_pub_key
return return
newenigmaPubKey = { new_enigma_pub_key = {
"name": "Enigma", "name": "Enigma",
"type": "PropertyValue", "type": "PropertyValue",
"value": enigmaPubKey "value": enigma_pub_key
} }
actor_json['attachment'].append(newenigmaPubKey) actor_json['attachment'].append(new_enigma_pub_key)