Snake case

merge-requests/30/head
Bob Mottram 2021-12-28 17:33:54 +00:00
parent 34e533f289
commit f75a321f9e
9 changed files with 109 additions and 109 deletions

View File

@ -8,7 +8,7 @@ __status__ = "Production"
__module_group__ = "Profile Metadata" __module_group__ = "Profile Metadata"
def getBriarAddress(actor_json: {}) -> str: def get_briar_address(actor_json: {}) -> str:
"""Returns briar address for the given actor """Returns briar address for the given actor
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
@ -43,7 +43,7 @@ def getBriarAddress(actor_json: {}) -> str:
return '' return ''
def setBriarAddress(actor_json: {}, briarAddress: str) -> None: def set_briar_address(actor_json: {}, briarAddress: str) -> None:
"""Sets an briar address for the given actor """Sets an briar address for the given actor
""" """
notBriarAddress = False notBriarAddress = False

View File

@ -10,7 +10,7 @@ __module_group__ = "Profile Metadata"
import re import re
def getCwtchAddress(actor_json: {}) -> str: def get_cwtch_address(actor_json: {}) -> str:
"""Returns cwtch address for the given actor """Returns cwtch address for the given actor
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
@ -41,7 +41,7 @@ def getCwtchAddress(actor_json: {}) -> str:
return '' return ''
def setCwtchAddress(actor_json: {}, cwtchAddress: str) -> None: def set_cwtch_address(actor_json: {}, cwtchAddress: str) -> None:
"""Sets an cwtch address for the given actor """Sets an cwtch address for the given actor
""" """
notCwtchAddress = False notCwtchAddress = False

124
daemon.py
View File

@ -31,24 +31,24 @@ from metadata import meta_data_node_info
from metadata import metadata_custom_emoji from metadata import metadata_custom_emoji
from enigma import get_enigma_pub_key from enigma import get_enigma_pub_key
from enigma import set_enigma_pub_key from enigma import set_enigma_pub_key
from pgp import getEmailAddress from pgp import get_email_address
from pgp import setEmailAddress from pgp import set_email_address
from pgp import getPGPpubKey from pgp import get_pgp_pub_key
from pgp import getPGPfingerprint from pgp import get_pgp_fingerprint
from pgp import setPGPpubKey from pgp import set_pgp_pub_key
from pgp import setPGPfingerprint from pgp import set_pgp_fingerprint
from xmpp import getXmppAddress from xmpp import get_xmpp_address
from xmpp import setXmppAddress from xmpp import set_xmpp_address
from ssb import getSSBAddress from ssb import get_ssb_address
from ssb import setSSBAddress from ssb import set_ssb_address
from tox import getToxAddress from tox import get_tox_address
from tox import setToxAddress from tox import set_tox_address
from briar import getBriarAddress from briar import get_briar_address
from briar import setBriarAddress from briar import set_briar_address
from jami import getJamiAddress from jami import get_jami_address
from jami import setJamiAddress from jami import set_jami_address
from cwtch import getCwtchAddress from cwtch import get_cwtch_address
from cwtch import setCwtchAddress from cwtch import set_cwtch_address
from matrix import getMatrixAddress from matrix import getMatrixAddress
from matrix import setMatrixAddress from matrix import setMatrixAddress
from donate import getDonationUrl from donate import getDonationUrl
@ -5264,26 +5264,26 @@ class PubServer(BaseHTTPRequestHandler):
'instanceDescription', '') 'instanceDescription', '')
# change email address # change email address
currentEmailAddress = getEmailAddress(actor_json) currentEmailAddress = get_email_address(actor_json)
if fields.get('email'): if fields.get('email'):
if fields['email'] != currentEmailAddress: if fields['email'] != currentEmailAddress:
setEmailAddress(actor_json, fields['email']) set_email_address(actor_json, fields['email'])
actorChanged = True actorChanged = True
else: else:
if currentEmailAddress: if currentEmailAddress:
setEmailAddress(actor_json, '') set_email_address(actor_json, '')
actorChanged = True actorChanged = True
# change xmpp address # change xmpp address
currentXmppAddress = getXmppAddress(actor_json) currentXmppAddress = get_xmpp_address(actor_json)
if fields.get('xmppAddress'): if fields.get('xmppAddress'):
if fields['xmppAddress'] != currentXmppAddress: if fields['xmppAddress'] != currentXmppAddress:
setXmppAddress(actor_json, set_xmpp_address(actor_json,
fields['xmppAddress']) fields['xmppAddress'])
actorChanged = True actorChanged = True
else: else:
if currentXmppAddress: if currentXmppAddress:
setXmppAddress(actor_json, '') set_xmpp_address(actor_json, '')
actorChanged = True actorChanged = True
# change matrix address # change matrix address
@ -5299,15 +5299,15 @@ class PubServer(BaseHTTPRequestHandler):
actorChanged = True actorChanged = True
# change SSB address # change SSB address
currentSSBAddress = getSSBAddress(actor_json) currentSSBAddress = get_ssb_address(actor_json)
if fields.get('ssbAddress'): if fields.get('ssbAddress'):
if fields['ssbAddress'] != currentSSBAddress: if fields['ssbAddress'] != currentSSBAddress:
setSSBAddress(actor_json, set_ssb_address(actor_json,
fields['ssbAddress']) fields['ssbAddress'])
actorChanged = True actorChanged = True
else: else:
if currentSSBAddress: if currentSSBAddress:
setSSBAddress(actor_json, '') set_ssb_address(actor_json, '')
actorChanged = True actorChanged = True
# change blog address # change blog address
@ -5335,51 +5335,51 @@ class PubServer(BaseHTTPRequestHandler):
actorChanged = True actorChanged = True
# change tox address # change tox address
currentToxAddress = getToxAddress(actor_json) currentToxAddress = get_tox_address(actor_json)
if fields.get('toxAddress'): if fields.get('toxAddress'):
if fields['toxAddress'] != currentToxAddress: if fields['toxAddress'] != currentToxAddress:
setToxAddress(actor_json, set_tox_address(actor_json,
fields['toxAddress']) fields['toxAddress'])
actorChanged = True actorChanged = True
else: else:
if currentToxAddress: if currentToxAddress:
setToxAddress(actor_json, '') set_tox_address(actor_json, '')
actorChanged = True actorChanged = True
# change briar address # change briar address
currentBriarAddress = getBriarAddress(actor_json) currentBriarAddress = get_briar_address(actor_json)
if fields.get('briarAddress'): if fields.get('briarAddress'):
if fields['briarAddress'] != currentBriarAddress: if fields['briarAddress'] != currentBriarAddress:
setBriarAddress(actor_json, set_briar_address(actor_json,
fields['briarAddress']) fields['briarAddress'])
actorChanged = True actorChanged = True
else: else:
if currentBriarAddress: if currentBriarAddress:
setBriarAddress(actor_json, '') set_briar_address(actor_json, '')
actorChanged = True actorChanged = True
# change jami address # change jami address
currentJamiAddress = getJamiAddress(actor_json) currentJamiAddress = get_jami_address(actor_json)
if fields.get('jamiAddress'): if fields.get('jamiAddress'):
if fields['jamiAddress'] != currentJamiAddress: if fields['jamiAddress'] != currentJamiAddress:
setJamiAddress(actor_json, set_jami_address(actor_json,
fields['jamiAddress']) fields['jamiAddress'])
actorChanged = True actorChanged = True
else: else:
if currentJamiAddress: if currentJamiAddress:
setJamiAddress(actor_json, '') set_jami_address(actor_json, '')
actorChanged = True actorChanged = True
# change cwtch address # change cwtch address
currentCwtchAddress = getCwtchAddress(actor_json) currentCwtchAddress = get_cwtch_address(actor_json)
if fields.get('cwtchAddress'): if fields.get('cwtchAddress'):
if fields['cwtchAddress'] != currentCwtchAddress: if fields['cwtchAddress'] != currentCwtchAddress:
setCwtchAddress(actor_json, set_cwtch_address(actor_json,
fields['cwtchAddress']) fields['cwtchAddress'])
actorChanged = True actorChanged = True
else: else:
if currentCwtchAddress: if currentCwtchAddress:
setCwtchAddress(actor_json, '') set_cwtch_address(actor_json, '')
actorChanged = True actorChanged = True
# change Enigma public key # change Enigma public key
@ -5395,27 +5395,27 @@ class PubServer(BaseHTTPRequestHandler):
actorChanged = True actorChanged = True
# change PGP public key # change PGP public key
currentPGPpubKey = getPGPpubKey(actor_json) currentPGPpubKey = get_pgp_pub_key(actor_json)
if fields.get('pgp'): if fields.get('pgp'):
if fields['pgp'] != currentPGPpubKey: if fields['pgp'] != currentPGPpubKey:
setPGPpubKey(actor_json, set_pgp_pub_key(actor_json,
fields['pgp']) fields['pgp'])
actorChanged = True actorChanged = True
else: else:
if currentPGPpubKey: if currentPGPpubKey:
setPGPpubKey(actor_json, '') set_pgp_pub_key(actor_json, '')
actorChanged = True actorChanged = True
# change PGP fingerprint # change PGP fingerprint
currentPGPfingerprint = getPGPfingerprint(actor_json) currentPGPfingerprint = get_pgp_fingerprint(actor_json)
if fields.get('openpgp'): if fields.get('openpgp'):
if fields['openpgp'] != currentPGPfingerprint: if fields['openpgp'] != currentPGPfingerprint:
setPGPfingerprint(actor_json, set_pgp_fingerprint(actor_json,
fields['openpgp']) fields['openpgp'])
actorChanged = True actorChanged = True
else: else:
if currentPGPfingerprint: if currentPGPfingerprint:
setPGPfingerprint(actor_json, '') set_pgp_fingerprint(actor_json, '')
actorChanged = True actorChanged = True
# change donation link # change donation link
@ -7113,18 +7113,18 @@ class PubServer(BaseHTTPRequestHandler):
lockedAccount = get_locked_account(actor_json) lockedAccount = get_locked_account(actor_json)
donateUrl = getDonationUrl(actor_json) donateUrl = getDonationUrl(actor_json)
websiteUrl = getWebsite(actor_json, self.server.translate) websiteUrl = getWebsite(actor_json, self.server.translate)
xmppAddress = getXmppAddress(actor_json) xmppAddress = get_xmpp_address(actor_json)
matrixAddress = getMatrixAddress(actor_json) matrixAddress = getMatrixAddress(actor_json)
ssbAddress = getSSBAddress(actor_json) ssbAddress = get_ssb_address(actor_json)
blogAddress = getBlogAddress(actor_json) blogAddress = getBlogAddress(actor_json)
toxAddress = getToxAddress(actor_json) toxAddress = get_tox_address(actor_json)
briarAddress = getBriarAddress(actor_json) briarAddress = get_briar_address(actor_json)
jamiAddress = getJamiAddress(actor_json) jamiAddress = get_jami_address(actor_json)
cwtchAddress = getCwtchAddress(actor_json) cwtchAddress = get_cwtch_address(actor_json)
emailAddress = getEmailAddress(actor_json) emailAddress = get_email_address(actor_json)
EnigmaPubKey = get_enigma_pub_key(actor_json) EnigmaPubKey = get_enigma_pub_key(actor_json)
PGPpubKey = getPGPpubKey(actor_json) PGPpubKey = get_pgp_pub_key(actor_json)
PGPfingerprint = getPGPfingerprint(actor_json) PGPfingerprint = get_pgp_fingerprint(actor_json)
if actor_json.get('alsoKnownAs'): if actor_json.get('alsoKnownAs'):
alsoKnownAs = actor_json['alsoKnownAs'] alsoKnownAs = actor_json['alsoKnownAs']

View File

@ -8,7 +8,7 @@ __status__ = "Production"
__module_group__ = "Profile Metadata" __module_group__ = "Profile Metadata"
def getJamiAddress(actor_json: {}) -> str: def get_jami_address(actor_json: {}) -> str:
"""Returns jami address for the given actor """Returns jami address for the given actor
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
@ -39,7 +39,7 @@ def getJamiAddress(actor_json: {}) -> str:
return '' return ''
def setJamiAddress(actor_json: {}, jamiAddress: str) -> None: def set_jami_address(actor_json: {}, jamiAddress: str) -> None:
"""Sets an jami address for the given actor """Sets an jami address for the given actor
""" """
notJamiAddress = False notJamiAddress = False

16
pgp.py
View File

@ -23,7 +23,7 @@ from auth import createBasicAuthHeader
from session import postJson from session import postJson
def getEmailAddress(actor_json: {}) -> str: def get_email_address(actor_json: {}) -> str:
"""Returns the email address for the given actor """Returns the email address for the given actor
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
@ -47,7 +47,7 @@ def getEmailAddress(actor_json: {}) -> str:
return '' return ''
def getPGPpubKey(actor_json: {}) -> str: def get_pgp_pub_key(actor_json: {}) -> str:
"""Returns PGP public key for the given actor """Returns PGP public key for the given actor
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
@ -69,7 +69,7 @@ def getPGPpubKey(actor_json: {}) -> str:
return '' return ''
def getPGPfingerprint(actor_json: {}) -> str: def get_pgp_fingerprint(actor_json: {}) -> str:
"""Returns PGP fingerprint for the given actor """Returns PGP fingerprint for the given actor
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
@ -91,7 +91,7 @@ def getPGPfingerprint(actor_json: {}) -> str:
return '' return ''
def setEmailAddress(actor_json: {}, emailAddress: str) -> None: def set_email_address(actor_json: {}, emailAddress: str) -> None:
"""Sets the email address for the given actor """Sets the email address for the given actor
""" """
notEmailAddress = False notEmailAddress = False
@ -143,7 +143,7 @@ def setEmailAddress(actor_json: {}, emailAddress: str) -> None:
actor_json['attachment'].append(newEmailAddress) actor_json['attachment'].append(newEmailAddress)
def setPGPpubKey(actor_json: {}, PGPpubKey: str) -> None: def set_pgp_pub_key(actor_json: {}, PGPpubKey: str) -> None:
"""Sets a PGP public key for the given actor """Sets a PGP public key for the given actor
""" """
removeKey = False removeKey = False
@ -194,7 +194,7 @@ def setPGPpubKey(actor_json: {}, PGPpubKey: str) -> None:
actor_json['attachment'].append(newPGPpubKey) actor_json['attachment'].append(newPGPpubKey)
def setPGPfingerprint(actor_json: {}, fingerprint: str) -> None: def set_pgp_fingerprint(actor_json: {}, fingerprint: str) -> None:
"""Sets a PGP fingerprint for the given actor """Sets a PGP fingerprint for the given actor
""" """
removeFingerprint = False removeFingerprint = False
@ -532,14 +532,14 @@ def pgpPublicKeyUpload(base_dir: str, session,
# set the pgp details # set the pgp details
if PGPpubKeyId: if PGPpubKeyId:
setPGPfingerprint(actor_json, PGPpubKeyId) set_pgp_fingerprint(actor_json, PGPpubKeyId)
else: else:
if debug: if debug:
print('No PGP key Id. Continuing anyway.') print('No PGP key Id. Continuing anyway.')
if debug: if debug:
print('Setting PGP key within ' + actor) print('Setting PGP key within ' + actor)
setPGPpubKey(actor_json, PGPpubKey) set_pgp_pub_key(actor_json, PGPpubKey)
# create an actor update # create an actor update
statusNumber, published = get_status_number() statusNumber, published = get_status_number()

4
ssb.py
View File

@ -8,7 +8,7 @@ __status__ = "Production"
__module_group__ = "Profile Metadata" __module_group__ = "Profile Metadata"
def getSSBAddress(actor_json: {}) -> str: def get_ssb_address(actor_json: {}) -> str:
"""Returns ssb address for the given actor """Returns ssb address for the given actor
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
@ -39,7 +39,7 @@ def getSSBAddress(actor_json: {}) -> str:
return '' return ''
def setSSBAddress(actor_json: {}, ssbAddress: str) -> None: def set_ssb_address(actor_json: {}, ssbAddress: str) -> None:
"""Sets an ssb address for the given actor """Sets an ssb address for the given actor
""" """
notSSBAddress = False notSSBAddress = False

4
tox.py
View File

@ -8,7 +8,7 @@ __status__ = "Production"
__module_group__ = "Profile Metadata" __module_group__ = "Profile Metadata"
def getToxAddress(actor_json: {}) -> str: def get_tox_address(actor_json: {}) -> str:
"""Returns tox address for the given actor """Returns tox address for the given actor
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
@ -41,7 +41,7 @@ def getToxAddress(actor_json: {}) -> str:
return '' return ''
def setToxAddress(actor_json: {}, toxAddress: str) -> None: def set_tox_address(actor_json: {}, toxAddress: str) -> None:
"""Sets an tox address for the given actor """Sets an tox address for the given actor
""" """
notToxAddress = False notToxAddress = False

View File

@ -41,17 +41,17 @@ from posts import parseUserFeed
from posts import isCreateInsideAnnounce from posts import isCreateInsideAnnounce
from donate import getDonationUrl from donate import getDonationUrl
from donate import getWebsite from donate import getWebsite
from xmpp import getXmppAddress from xmpp import get_xmpp_address
from matrix import getMatrixAddress from matrix import getMatrixAddress
from ssb import getSSBAddress from ssb import get_ssb_address
from pgp import getEmailAddress from pgp import get_email_address
from pgp import getPGPfingerprint from pgp import get_pgp_fingerprint
from pgp import getPGPpubKey from pgp import get_pgp_pub_key
from enigma import get_enigma_pub_key from enigma import get_enigma_pub_key
from tox import getToxAddress from tox import get_tox_address
from briar import getBriarAddress from briar import get_briar_address
from jami import getJamiAddress from jami import get_jami_address
from cwtch import getCwtchAddress from cwtch import get_cwtch_address
from filters import isFiltered from filters import isFiltered
from follow import isFollowerOfPerson from follow import isFollowerOfPerson
from follow import getFollowerDomains from follow import getFollowerDomains
@ -636,16 +636,16 @@ def htmlProfile(signing_priv_key_pem: str,
websiteUrl = getWebsite(profile_json, translate) websiteUrl = getWebsite(profile_json, translate)
blogAddress = getBlogAddress(profile_json) blogAddress = getBlogAddress(profile_json)
EnigmaPubKey = get_enigma_pub_key(profile_json) EnigmaPubKey = get_enigma_pub_key(profile_json)
PGPpubKey = getPGPpubKey(profile_json) PGPpubKey = get_pgp_pub_key(profile_json)
PGPfingerprint = getPGPfingerprint(profile_json) PGPfingerprint = get_pgp_fingerprint(profile_json)
emailAddress = getEmailAddress(profile_json) emailAddress = get_email_address(profile_json)
xmppAddress = getXmppAddress(profile_json) xmppAddress = get_xmpp_address(profile_json)
matrixAddress = getMatrixAddress(profile_json) matrixAddress = getMatrixAddress(profile_json)
ssbAddress = getSSBAddress(profile_json) ssbAddress = get_ssb_address(profile_json)
toxAddress = getToxAddress(profile_json) toxAddress = get_tox_address(profile_json)
briarAddress = getBriarAddress(profile_json) briarAddress = get_briar_address(profile_json)
jamiAddress = getJamiAddress(profile_json) jamiAddress = get_jami_address(profile_json)
cwtchAddress = getCwtchAddress(profile_json) cwtchAddress = get_cwtch_address(profile_json)
if donateUrl or websiteUrl or xmppAddress or matrixAddress or \ if donateUrl or websiteUrl or xmppAddress or matrixAddress or \
ssbAddress or toxAddress or briarAddress or \ ssbAddress or toxAddress or briarAddress or \
jamiAddress or cwtchAddress or PGPpubKey or EnigmaPubKey or \ jamiAddress or cwtchAddress or PGPpubKey or EnigmaPubKey or \
@ -2132,18 +2132,18 @@ def htmlEditProfile(css_cache: {}, translate: {}, base_dir: str, path: str,
movedTo = actor_json['movedTo'] movedTo = actor_json['movedTo']
donateUrl = getDonationUrl(actor_json) donateUrl = getDonationUrl(actor_json)
websiteUrl = getWebsite(actor_json, translate) websiteUrl = getWebsite(actor_json, translate)
xmppAddress = getXmppAddress(actor_json) xmppAddress = get_xmpp_address(actor_json)
matrixAddress = getMatrixAddress(actor_json) matrixAddress = getMatrixAddress(actor_json)
ssbAddress = getSSBAddress(actor_json) ssbAddress = get_ssb_address(actor_json)
blogAddress = getBlogAddress(actor_json) blogAddress = getBlogAddress(actor_json)
toxAddress = getToxAddress(actor_json) toxAddress = get_tox_address(actor_json)
briarAddress = getBriarAddress(actor_json) briarAddress = get_briar_address(actor_json)
jamiAddress = getJamiAddress(actor_json) jamiAddress = get_jami_address(actor_json)
cwtchAddress = getCwtchAddress(actor_json) cwtchAddress = get_cwtch_address(actor_json)
emailAddress = getEmailAddress(actor_json) emailAddress = get_email_address(actor_json)
EnigmaPubKey = get_enigma_pub_key(actor_json) EnigmaPubKey = get_enigma_pub_key(actor_json)
PGPpubKey = getPGPpubKey(actor_json) PGPpubKey = get_pgp_pub_key(actor_json)
PGPfingerprint = getPGPfingerprint(actor_json) PGPfingerprint = get_pgp_fingerprint(actor_json)
if actor_json.get('name'): if actor_json.get('name'):
if not isFiltered(base_dir, nickname, domain, actor_json['name']): if not isFiltered(base_dir, nickname, domain, actor_json['name']):
displayNickname = actor_json['name'] displayNickname = actor_json['name']

View File

@ -8,7 +8,7 @@ __status__ = "Production"
__module_group__ = "Profile Metadata" __module_group__ = "Profile Metadata"
def getXmppAddress(actor_json: {}) -> str: def get_xmpp_address(actor_json: {}) -> str:
"""Returns xmpp address for the given actor """Returns xmpp address for the given actor
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
@ -34,7 +34,7 @@ def getXmppAddress(actor_json: {}) -> str:
return '' return ''
def setXmppAddress(actor_json: {}, xmppAddress: str) -> None: def set_xmpp_address(actor_json: {}, xmppAddress: str) -> None:
"""Sets an xmpp address for the given actor """Sets an xmpp address for the given actor
""" """
notXmppAddress = False notXmppAddress = False