Snake case

main
Bob Mottram 2021-12-26 10:32:45 +00:00
parent c99a29df89
commit 164393cd3d
15 changed files with 324 additions and 324 deletions

View File

@ -13,33 +13,33 @@ def getBriarAddress(actor_json: {}) -> str:
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue['name'].lower().startswith('briar'): if not property_value['name'].lower().startswith('briar'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue.get('value'): if not property_value.get('value'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
propertyValue['value'] = propertyValue['value'].strip() property_value['value'] = property_value['value'].strip()
if len(propertyValue['value']) < 50: if len(property_value['value']) < 50:
continue continue
if not propertyValue['value'].startswith('briar://'): if not property_value['value'].startswith('briar://'):
continue continue
if propertyValue['value'].lower() != propertyValue['value']: if property_value['value'].lower() != property_value['value']:
continue continue
if '"' in propertyValue['value']: if '"' in property_value['value']:
continue continue
if ' ' in propertyValue['value']: if ' ' in property_value['value']:
continue continue
if ',' in propertyValue['value']: if ',' in property_value['value']:
continue continue
if '.' in propertyValue['value']: if '.' in property_value['value']:
continue continue
return propertyValue['value'] return property_value['value']
return '' return ''
@ -70,30 +70,30 @@ def setBriarAddress(actor_json: {}, briarAddress: str) -> None:
# remove any existing value # remove any existing value
propertyFound = None propertyFound = None
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('briar'): if not property_value['name'].lower().startswith('briar'):
continue continue
propertyFound = propertyValue propertyFound = property_value
break break
if propertyFound: if propertyFound:
actor_json['attachment'].remove(propertyFound) actor_json['attachment'].remove(propertyFound)
if notBriarAddress: if notBriarAddress:
return return
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('briar'): if not property_value['name'].lower().startswith('briar'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
propertyValue['value'] = briarAddress property_value['value'] = briarAddress
return return
newBriarAddress = { newBriarAddress = {

View File

@ -15,29 +15,29 @@ def getCwtchAddress(actor_json: {}) -> str:
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue['name'].lower().startswith('cwtch'): if not property_value['name'].lower().startswith('cwtch'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue.get('value'): if not property_value.get('value'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
propertyValue['value'] = propertyValue['value'].strip() property_value['value'] = property_value['value'].strip()
if len(propertyValue['value']) < 2: if len(property_value['value']) < 2:
continue continue
if '"' in propertyValue['value']: if '"' in property_value['value']:
continue continue
if ' ' in propertyValue['value']: if ' ' in property_value['value']:
continue continue
if ',' in propertyValue['value']: if ',' in property_value['value']:
continue continue
if '.' in propertyValue['value']: if '.' in property_value['value']:
continue continue
return propertyValue['value'] return property_value['value']
return '' return ''
@ -58,30 +58,30 @@ def setCwtchAddress(actor_json: {}, cwtchAddress: str) -> None:
# remove any existing value # remove any existing value
propertyFound = None propertyFound = None
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('cwtch'): if not property_value['name'].lower().startswith('cwtch'):
continue continue
propertyFound = propertyValue propertyFound = property_value
break break
if propertyFound: if propertyFound:
actor_json['attachment'].remove(propertyFound) actor_json['attachment'].remove(propertyFound)
if notCwtchAddress: if notCwtchAddress:
return return
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('cwtch'): if not property_value['name'].lower().startswith('cwtch'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
propertyValue['value'] = cwtchAddress property_value['value'] = cwtchAddress
return return
newCwtchAddress = { newCwtchAddress = {

View File

@ -24,20 +24,20 @@ def getDonationUrl(actor_json: {}) -> str:
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
donationType = _getDonationTypes() donationType = _getDonationTypes()
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if propertyValue['name'].lower() not in donationType: if property_value['name'].lower() not in donationType:
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue.get('value'): if not property_value.get('value'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
if '<a href="' not in propertyValue['value']: if '<a href="' not in property_value['value']:
continue continue
donateUrl = propertyValue['value'].split('<a href="')[1] donateUrl = property_value['value'].split('<a href="')[1]
if '"' in donateUrl: if '"' in donateUrl:
return donateUrl.split('"')[0] return donateUrl.split('"')[0]
return '' return ''
@ -50,18 +50,18 @@ def getWebsite(actor_json: {}, translate: {}) -> str:
return '' return ''
matchStrings = _getWebsiteStrings() matchStrings = _getWebsiteStrings()
matchStrings.append(translate['Website'].lower()) matchStrings.append(translate['Website'].lower())
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if propertyValue['name'].lower() not in matchStrings: if property_value['name'].lower() not in matchStrings:
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue.get('value'): if not property_value.get('value'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
return propertyValue['value'] return property_value['value']
return '' return ''
@ -91,14 +91,14 @@ def setDonationUrl(actor_json: {}, donateUrl: str) -> None:
# remove any existing value # remove any existing value
propertyFound = None propertyFound = None
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower() != donateName: if not property_value['name'].lower() != donateName:
continue continue
propertyFound = propertyValue propertyFound = property_value
break break
if propertyFound: if propertyFound:
actor_json['attachment'].remove(propertyFound) actor_json['attachment'].remove(propertyFound)
@ -110,16 +110,16 @@ def setDonationUrl(actor_json: {}, donateUrl: str) -> None:
'" rel="me nofollow noopener noreferrer" target="_blank">' + \ '" rel="me nofollow noopener noreferrer" target="_blank">' + \
donateUrl + '</a>' donateUrl + '</a>'
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if propertyValue['name'].lower() != donateName: if property_value['name'].lower() != donateName:
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
propertyValue['value'] = donateValue property_value['value'] = donateValue
return return
newDonate = { newDonate = {
@ -152,14 +152,14 @@ def setWebsite(actor_json: {}, websiteUrl: str, translate: {}) -> None:
# remove any existing value # remove any existing value
propertyFound = None propertyFound = None
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if propertyValue['name'].lower() not in matchStrings: if property_value['name'].lower() not in matchStrings:
continue continue
propertyFound = propertyValue propertyFound = property_value
break break
if propertyFound: if propertyFound:
actor_json['attachment'].remove(propertyFound) actor_json['attachment'].remove(propertyFound)

View File

@ -13,18 +13,18 @@ def getEnigmaPubKey(actor_json: {}) -> str:
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue['name'].lower().startswith('enigma'): if not property_value['name'].lower().startswith('enigma'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue.get('value'): if not property_value.get('value'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
return propertyValue['value'] return property_value['value']
return '' return ''
@ -40,30 +40,30 @@ def setEnigmaPubKey(actor_json: {}, enigmaPubKey: str) -> None:
# remove any existing value # remove any existing value
propertyFound = None propertyFound = None
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('enigma'): if not property_value['name'].lower().startswith('enigma'):
continue continue
propertyFound = propertyValue propertyFound = property_value
break break
if propertyFound: if propertyFound:
actor_json['attachment'].remove(propertyValue) actor_json['attachment'].remove(property_value)
if removeKey: if removeKey:
return return
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('enigma'): if not property_value['name'].lower().startswith('enigma'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
propertyValue['value'] = enigmaPubKey property_value['value'] = enigmaPubKey
return return
newenigmaPubKey = { newenigmaPubKey = {

48
jami.py
View File

@ -13,29 +13,29 @@ def getJamiAddress(actor_json: {}) -> str:
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue['name'].lower().startswith('jami'): if not property_value['name'].lower().startswith('jami'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue.get('value'): if not property_value.get('value'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
propertyValue['value'] = propertyValue['value'].strip() property_value['value'] = property_value['value'].strip()
if len(propertyValue['value']) < 2: if len(property_value['value']) < 2:
continue continue
if '"' in propertyValue['value']: if '"' in property_value['value']:
continue continue
if ' ' in propertyValue['value']: if ' ' in property_value['value']:
continue continue
if ',' in propertyValue['value']: if ',' in property_value['value']:
continue continue
if '.' in propertyValue['value']: if '.' in property_value['value']:
continue continue
return propertyValue['value'] return property_value['value']
return '' return ''
@ -62,30 +62,30 @@ def setJamiAddress(actor_json: {}, jamiAddress: str) -> None:
# remove any existing value # remove any existing value
propertyFound = None propertyFound = None
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('jami'): if not property_value['name'].lower().startswith('jami'):
continue continue
propertyFound = propertyValue propertyFound = property_value
break break
if propertyFound: if propertyFound:
actor_json['attachment'].remove(propertyFound) actor_json['attachment'].remove(propertyFound)
if notJamiAddress: if notJamiAddress:
return return
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('jami'): if not property_value['name'].lower().startswith('jami'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
propertyValue['value'] = jamiAddress property_value['value'] = jamiAddress
return return
newJamiAddress = { newJamiAddress = {

View File

@ -67,14 +67,14 @@ def setActorLanguages(base_dir: str, actor_json: {},
# remove any existing value # remove any existing value
propertyFound = None propertyFound = None
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('languages'): if not property_value['name'].lower().startswith('languages'):
continue continue
propertyFound = propertyValue propertyFound = property_value
break break
if propertyFound: if propertyFound:
actor_json['attachment'].remove(propertyFound) actor_json['attachment'].remove(propertyFound)

View File

@ -13,26 +13,26 @@ def getMatrixAddress(actor_json: {}) -> str:
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue['name'].lower().startswith('matrix'): if not property_value['name'].lower().startswith('matrix'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue.get('value'): if not property_value.get('value'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
if '@' not in propertyValue['value']: if '@' not in property_value['value']:
continue continue
if not propertyValue['value'].startswith('@'): if not property_value['value'].startswith('@'):
continue continue
if ':' not in propertyValue['value']: if ':' not in property_value['value']:
continue continue
if '"' in propertyValue['value']: if '"' in property_value['value']:
continue continue
return propertyValue['value'] return property_value['value']
return '' return ''
@ -44,14 +44,14 @@ def setMatrixAddress(actor_json: {}, matrixAddress: str) -> None:
# remove any existing value # remove any existing value
propertyFound = None propertyFound = None
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('matrix'): if not property_value['name'].lower().startswith('matrix'):
continue continue
propertyFound = propertyValue propertyFound = property_value
break break
if propertyFound: if propertyFound:
actor_json['attachment'].remove(propertyFound) actor_json['attachment'].remove(propertyFound)
@ -69,16 +69,16 @@ def setMatrixAddress(actor_json: {}, matrixAddress: str) -> None:
if ':' not in matrixAddress: if ':' not in matrixAddress:
return return
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('matrix'): if not property_value['name'].lower().startswith('matrix'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
propertyValue['value'] = matrixAddress property_value['value'] = matrixAddress
return return
newMatrixAddress = { newMatrixAddress = {

120
pgp.py
View File

@ -28,22 +28,22 @@ def getEmailAddress(actor_json: {}) -> str:
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue['name'].lower().startswith('email'): if not property_value['name'].lower().startswith('email'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue.get('value'): if not property_value.get('value'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
if '@' not in propertyValue['value']: if '@' not in property_value['value']:
continue continue
if '.' not in propertyValue['value']: if '.' not in property_value['value']:
continue continue
return propertyValue['value'] return property_value['value']
return '' return ''
@ -52,20 +52,20 @@ def getPGPpubKey(actor_json: {}) -> str:
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue['name'].lower().startswith('pgp'): if not property_value['name'].lower().startswith('pgp'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue.get('value'): if not property_value.get('value'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
if not containsPGPPublicKey(propertyValue['value']): if not containsPGPPublicKey(property_value['value']):
continue continue
return propertyValue['value'] return property_value['value']
return '' return ''
@ -74,20 +74,20 @@ def getPGPfingerprint(actor_json: {}) -> str:
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue['name'].lower().startswith('openpgp'): if not property_value['name'].lower().startswith('openpgp'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue.get('value'): if not property_value.get('value'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
if len(propertyValue['value']) < 10: if len(property_value['value']) < 10:
continue continue
return propertyValue['value'] return property_value['value']
return '' return ''
@ -109,30 +109,30 @@ def setEmailAddress(actor_json: {}, emailAddress: str) -> None:
# remove any existing value # remove any existing value
propertyFound = None propertyFound = None
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('email'): if not property_value['name'].lower().startswith('email'):
continue continue
propertyFound = propertyValue propertyFound = property_value
break break
if propertyFound: if propertyFound:
actor_json['attachment'].remove(propertyFound) actor_json['attachment'].remove(propertyFound)
if notEmailAddress: if notEmailAddress:
return return
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('email'): if not property_value['name'].lower().startswith('email'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
propertyValue['value'] = emailAddress property_value['value'] = emailAddress
return return
newEmailAddress = { newEmailAddress = {
@ -160,30 +160,30 @@ def setPGPpubKey(actor_json: {}, PGPpubKey: str) -> None:
# remove any existing value # remove any existing value
propertyFound = None propertyFound = None
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('pgp'): if not property_value['name'].lower().startswith('pgp'):
continue continue
propertyFound = propertyValue propertyFound = property_value
break break
if propertyFound: if propertyFound:
actor_json['attachment'].remove(propertyValue) actor_json['attachment'].remove(property_value)
if removeKey: if removeKey:
return return
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('pgp'): if not property_value['name'].lower().startswith('pgp'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
propertyValue['value'] = PGPpubKey property_value['value'] = PGPpubKey
return return
newPGPpubKey = { newPGPpubKey = {
@ -209,30 +209,30 @@ def setPGPfingerprint(actor_json: {}, fingerprint: str) -> None:
# remove any existing value # remove any existing value
propertyFound = None propertyFound = None
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('openpgp'): if not property_value['name'].lower().startswith('openpgp'):
continue continue
propertyFound = propertyValue propertyFound = property_value
break break
if propertyFound: if propertyFound:
actor_json['attachment'].remove(propertyValue) actor_json['attachment'].remove(property_value)
if removeFingerprint: if removeFingerprint:
return return
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('openpgp'): if not property_value['name'].lower().startswith('openpgp'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
propertyValue['value'] = fingerprint.strip() property_value['value'] = fingerprint.strip()
return return
newPGPfingerprint = { newPGPfingerprint = {

48
ssb.py
View File

@ -13,29 +13,29 @@ def getSSBAddress(actor_json: {}) -> str:
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue['name'].lower().startswith('ssb'): if not property_value['name'].lower().startswith('ssb'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue.get('value'): if not property_value.get('value'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
propertyValue['value'] = propertyValue['value'].strip() property_value['value'] = property_value['value'].strip()
if not propertyValue['value'].startswith('@'): if not property_value['value'].startswith('@'):
continue continue
if '=.' not in propertyValue['value']: if '=.' not in property_value['value']:
continue continue
if '"' in propertyValue['value']: if '"' in property_value['value']:
continue continue
if ' ' in propertyValue['value']: if ' ' in property_value['value']:
continue continue
if ',' in propertyValue['value']: if ',' in property_value['value']:
continue continue
return propertyValue['value'] return property_value['value']
return '' return ''
@ -61,30 +61,30 @@ def setSSBAddress(actor_json: {}, ssbAddress: str) -> None:
# remove any existing value # remove any existing value
propertyFound = None propertyFound = None
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('ssb'): if not property_value['name'].lower().startswith('ssb'):
continue continue
propertyFound = propertyValue propertyFound = property_value
break break
if propertyFound: if propertyFound:
actor_json['attachment'].remove(propertyFound) actor_json['attachment'].remove(propertyFound)
if notSSBAddress: if notSSBAddress:
return return
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('ssb'): if not property_value['name'].lower().startswith('ssb'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
propertyValue['value'] = ssbAddress property_value['value'] = ssbAddress
return return
newSSBAddress = { newSSBAddress = {

View File

@ -5160,10 +5160,10 @@ def testUpdateActor(base_dir: str):
print("actor_json['attachment'] has no contents") print("actor_json['attachment'] has no contents")
assert len(actor_json['attachment']) > 0 assert len(actor_json['attachment']) > 0
propertyFound = False propertyFound = False
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if propertyValue['name'] == 'PGP': if property_value['name'] == 'PGP':
print('PGP property set within attachment') print('PGP property set within attachment')
assert pubKey in propertyValue['value'] assert pubKey in property_value['value']
propertyFound = True propertyFound = True
assert propertyFound assert propertyFound

50
tox.py
View File

@ -13,31 +13,31 @@ def getToxAddress(actor_json: {}) -> str:
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue['name'].lower().startswith('tox'): if not property_value['name'].lower().startswith('tox'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue.get('value'): if not property_value.get('value'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
propertyValue['value'] = propertyValue['value'].strip() property_value['value'] = property_value['value'].strip()
if len(propertyValue['value']) != 76: if len(property_value['value']) != 76:
continue continue
if propertyValue['value'].upper() != propertyValue['value']: if property_value['value'].upper() != property_value['value']:
continue continue
if '"' in propertyValue['value']: if '"' in property_value['value']:
continue continue
if ' ' in propertyValue['value']: if ' ' in property_value['value']:
continue continue
if ',' in propertyValue['value']: if ',' in property_value['value']:
continue continue
if '.' in propertyValue['value']: if '.' in property_value['value']:
continue continue
return propertyValue['value'] return property_value['value']
return '' return ''
@ -66,30 +66,30 @@ def setToxAddress(actor_json: {}, toxAddress: str) -> None:
# remove any existing value # remove any existing value
propertyFound = None propertyFound = None
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('tox'): if not property_value['name'].lower().startswith('tox'):
continue continue
propertyFound = propertyValue propertyFound = property_value
break break
if propertyFound: if propertyFound:
actor_json['attachment'].remove(propertyFound) actor_json['attachment'].remove(propertyFound)
if notToxAddress: if notToxAddress:
return return
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith('tox'): if not property_value['name'].lower().startswith('tox'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
propertyValue['value'] = toxAddress property_value['value'] = toxAddress
return return
newToxAddress = { newToxAddress = {

View File

@ -39,23 +39,23 @@ def get_actor_languages_list(actor_json: {}) -> []:
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return [] return []
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue['name'].lower().startswith('languages'): if not property_value['name'].lower().startswith('languages'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue.get('value'): if not property_value.get('value'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
if isinstance(propertyValue['value'], list): if isinstance(property_value['value'], list):
langList = propertyValue['value'] langList = property_value['value']
langList.sort() langList.sort()
return langList return langList
elif isinstance(propertyValue['value'], str): elif isinstance(property_value['value'], str):
langStr = propertyValue['value'] langStr = property_value['value']
langListTemp = [] langListTemp = []
if ',' in langStr: if ',' in langStr:
langListTemp = langStr.split(',') langListTemp = langStr.split(',')
@ -2874,33 +2874,33 @@ def getActorPropertyUrl(actor_json: {}, propertyName: str) -> str:
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
propertyName = propertyName.lower() propertyName = propertyName.lower()
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue['name'].lower().startswith(propertyName): if not property_value['name'].lower().startswith(propertyName):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue.get('value'): if not property_value.get('value'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
propertyValue['value'] = propertyValue['value'].strip() property_value['value'] = property_value['value'].strip()
prefixes = getProtocolPrefixes() prefixes = getProtocolPrefixes()
prefixFound = False prefixFound = False
for prefix in prefixes: for prefix in prefixes:
if propertyValue['value'].startswith(prefix): if property_value['value'].startswith(prefix):
prefixFound = True prefixFound = True
break break
if not prefixFound: if not prefixFound:
continue continue
if '.' not in propertyValue['value']: if '.' not in property_value['value']:
continue continue
if ' ' in propertyValue['value']: if ' ' in property_value['value']:
continue continue
if ',' in propertyValue['value']: if ',' in property_value['value']:
continue continue
return propertyValue['value'] return property_value['value']
return '' return ''

View File

@ -180,14 +180,14 @@ def _setActorPropertyUrl(actor_json: {}, propertyName: str, url: str) -> None:
# remove any existing value # remove any existing value
propertyFound = None propertyFound = None
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith(propertyNameLower): if not property_value['name'].lower().startswith(propertyNameLower):
continue continue
propertyFound = propertyValue propertyFound = property_value
break break
if propertyFound: if propertyFound:
actor_json['attachment'].remove(propertyFound) actor_json['attachment'].remove(propertyFound)
@ -207,16 +207,16 @@ def _setActorPropertyUrl(actor_json: {}, propertyName: str, url: str) -> None:
if ',' in url: if ',' in url:
return return
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue['name'].lower().startswith(propertyNameLower): if not property_value['name'].lower().startswith(propertyNameLower):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
propertyValue['value'] = url property_value['value'] = url
return return
newAddress = { newAddress = {

View File

@ -361,10 +361,10 @@ def _webfingerUpdateFromProfile(wfJson: {}, actor_json: {}) -> bool:
for name, alias in webfingerPropertyName.items(): for name, alias in webfingerPropertyName.items():
aliasesNotFound.append(alias) aliasesNotFound.append(alias)
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
propertyName = propertyValue['name'].lower() propertyName = property_value['name'].lower()
found = False found = False
for name, alias in webfingerPropertyName.items(): for name, alias in webfingerPropertyName.items():
if name == propertyName: if name == propertyName:
@ -374,14 +374,14 @@ def _webfingerUpdateFromProfile(wfJson: {}, actor_json: {}) -> bool:
break break
if not found: if not found:
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue.get('value'): if not property_value.get('value'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
newValue = propertyValue['value'].strip() newValue = property_value['value'].strip()
if '://' in newValue: if '://' in newValue:
newValue = newValue.split('://')[1] newValue = newValue.split('://')[1]

42
xmpp.py
View File

@ -13,24 +13,24 @@ def getXmppAddress(actor_json: {}) -> str:
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
nameLower = propertyValue['name'].lower() nameLower = property_value['name'].lower()
if not (nameLower.startswith('xmpp') or if not (nameLower.startswith('xmpp') or
nameLower.startswith('jabber')): nameLower.startswith('jabber')):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not propertyValue.get('value'): if not property_value.get('value'):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
if '@' not in propertyValue['value']: if '@' not in property_value['value']:
continue continue
if '"' in propertyValue['value']: if '"' in property_value['value']:
continue continue
return propertyValue['value'] return property_value['value']
return '' return ''
@ -52,33 +52,33 @@ def setXmppAddress(actor_json: {}, xmppAddress: str) -> None:
# remove any existing value # remove any existing value
propertyFound = None propertyFound = None
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
if not (propertyValue['name'].lower().startswith('xmpp') or if not (property_value['name'].lower().startswith('xmpp') or
propertyValue['name'].lower().startswith('jabber')): property_value['name'].lower().startswith('jabber')):
continue continue
propertyFound = propertyValue propertyFound = property_value
break break
if propertyFound: if propertyFound:
actor_json['attachment'].remove(propertyFound) actor_json['attachment'].remove(propertyFound)
if notXmppAddress: if notXmppAddress:
return return
for propertyValue in actor_json['attachment']: for property_value in actor_json['attachment']:
if not propertyValue.get('name'): if not property_value.get('name'):
continue continue
if not propertyValue.get('type'): if not property_value.get('type'):
continue continue
nameLower = propertyValue['name'].lower() nameLower = property_value['name'].lower()
if not (nameLower.startswith('xmpp') or if not (nameLower.startswith('xmpp') or
nameLower.startswith('jabber')): nameLower.startswith('jabber')):
continue continue
if propertyValue['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
propertyValue['value'] = xmppAddress property_value['value'] = xmppAddress
return return
newXmppAddress = { newXmppAddress = {