Snake case

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

View File

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

View File

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

View File

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

48
jami.py
View File

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

View File

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

View File

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

120
pgp.py
View File

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

48
ssb.py
View File

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

View File

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

50
tox.py
View File

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

View File

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

View File

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

View File

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

42
xmpp.py
View File

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