Check property types

main
bashrc 2026-05-05 13:54:24 +01:00
parent 258562f8aa
commit c66ebe888a
18 changed files with 115 additions and 73 deletions

View File

@ -115,7 +115,7 @@ def set_briar_address(actor_json: {}, briar_address: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name']

View File

@ -103,7 +103,7 @@ def set_cwtch_address(actor_json: {}, cwtch_address: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name']

View File

@ -62,7 +62,7 @@ def set_discord(actor_json: {}, discord: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'].lower()

View File

@ -86,7 +86,7 @@ def set_enigma_pub_key(actor_json: {}, enigma_pub_key: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name']

View File

@ -83,11 +83,13 @@ def set_actor_languages(actor_json: {}, languages_str: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
name_value = property_value['name']
if isinstance(property_value['name'], str):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name']
if not name_value:
continue
if not property_value.get('type'):

View File

@ -68,11 +68,13 @@ def set_music_site_url(actor_json: {}, music_site_url: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
name_value = property_value['name'].lower()
if isinstance(property_value['name'], str):
name_value = property_value['name'].lower()
elif property_value.get('schema:name'):
name_value = property_value['schema:name'].lower()
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'].lower()
if not name_value:
continue
if not property_value.get('type'):
@ -89,11 +91,13 @@ def set_music_site_url(actor_json: {}, music_site_url: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
name_value = property_value['name']
if isinstance(property_value['name'], str):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name']
if not name_value:
continue
if not property_value.get('type'):

View File

@ -197,11 +197,13 @@ def _person_receive_update_outbox(base_dir: str, http_prefix: str,
updatable_attachments = ('PGP', 'OpenPGP', 'Email')
for new_property_value in updated_actor_json['attachment']:
name_value = None
name_value: str = None
if new_property_value.get('name'):
name_value = new_property_value['name']
if isinstance(new_property_value['name'], str):
name_value = new_property_value['name']
elif new_property_value.get('schema:name'):
name_value = new_property_value['schema:name']
if isinstance(new_property_value['schema:name'], str):
name_value = new_property_value['schema:name']
if not name_value:
continue
if name_value not in updatable_attachments:

View File

@ -79,7 +79,7 @@ def set_peertube(actor_json: {}, peertube: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'].lower()

6
pgp.py
View File

@ -178,7 +178,7 @@ def get_pgp_fingerprint(actor_json: {}) -> str:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name']
@ -225,7 +225,7 @@ def set_email_address(actor_json: {}, email_address: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name']
@ -374,7 +374,7 @@ def set_pgp_pub_key(actor_json: {}, pgp_pub_key: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name']

View File

@ -102,7 +102,7 @@ def set_pixelfed(actor_json: {}, pixelfed: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'].lower()
@ -125,7 +125,7 @@ def set_pixelfed(actor_json: {}, pixelfed: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name']

View File

@ -85,7 +85,7 @@ def set_pronouns(actor_json: {}, pronouns: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name']

16
ssb.py
View File

@ -84,11 +84,13 @@ def set_ssb_address(actor_json: {}, ssb_address: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
name_value = property_value['name']
if isinstance(property_value['name'], str):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name']
if not name_value:
continue
if not property_value.get('type'):
@ -106,11 +108,13 @@ def set_ssb_address(actor_json: {}, ssb_address: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
name_value = property_value['name']
if isinstance(property_value['name'], str):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name']
if not name_value:
continue
if not property_value.get('type'):

24
tox.py
View File

@ -23,11 +23,13 @@ def get_tox_address(actor_json: {}) -> str:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
name_value = property_value['name']
if isinstance(property_value['name'], str):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name']
if not name_value:
continue
if not name_value.lower().startswith('tox'):
@ -88,11 +90,13 @@ def set_tox_address(actor_json: {}, tox_address: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
name_value = property_value['name']
if isinstance(property_value['name'], str):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name']
if not name_value:
continue
if not property_value.get('type'):
@ -110,11 +114,13 @@ def set_tox_address(actor_json: {}, tox_address: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
name_value = property_value['name']
if isinstance(property_value['name'], str):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name']
if not name_value:
continue
if not property_value.get('type'):

View File

@ -181,11 +181,13 @@ def get_actor_languages_list(actor_json: {}) -> []:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
name_value = property_value['name']
if isinstance(property_value['name'], str):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name']
if not name_value:
continue
if not name_value.lower().startswith('languages'):
@ -1389,9 +1391,11 @@ def get_gender_from_bio(base_dir: str, actor: str, person_cache: {},
continue
name_value = None
if tag.get('name'):
name_value = tag['name']
if isinstance(tag['name'], str):
name_value = tag['name']
if tag.get('schema:name'):
name_value = tag['schema:name']
if isinstance(tag['schema:name'], str):
name_value = tag['schema:name']
if not name_value:
continue
prop_value_name, _ = get_attachment_property_value(tag)
@ -2868,14 +2872,16 @@ def get_actor_property_url(actor_json: {}, property_name: str) -> str:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if not isinstance(property_value, dict):
print("WARN: Actor attachment is not dict: " + str(property_value))
continue
if property_value.get('name'):
name_value = property_value['name']
if isinstance(property_value['name'], str):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name']
if not name_value:
continue
name_value_lower = name_value.lower()

View File

@ -311,11 +311,13 @@ def _set_actor_property_url(actor_json: {},
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
name_value = property_value['name']
if isinstance(property_value['name'], str):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name']
if not name_value:
continue
if not property_value.get('type'):
@ -346,11 +348,13 @@ def _set_actor_property_url(actor_json: {},
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
name_value = property_value['name']
if isinstance(property_value['name'], str):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name']
if not name_value:
continue
if not property_value.get('type'):

View File

@ -550,11 +550,13 @@ def _webfinger_update_from_profile(wf_json: {}, actor_json: {}) -> bool:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
name_value = property_value['name']
if isinstance(property_value['name'], str):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name']
if not name_value:
continue
property_name = name_value.lower()

24
xmpp.py
View File

@ -23,11 +23,13 @@ def get_xmpp_address(actor_json: {}) -> str:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
name_value = property_value['name'].lower()
if isinstance(property_value['name'], str):
name_value = property_value['name'].lower()
elif property_value.get('schema:name'):
name_value = property_value['schema:name'].lower()
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'].lower()
if not name_value:
continue
if not (name_value.startswith('xmpp') or
@ -82,11 +84,13 @@ def set_xmpp_address(actor_json: {}, xmpp_address: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
name_value = property_value['name']
if isinstance(property_value['name'], str):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name']
if not name_value:
continue
if not property_value.get('type'):
@ -113,11 +117,13 @@ def set_xmpp_address(actor_json: {}, xmpp_address: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
name_value = property_value['name']
if isinstance(property_value['name'], str):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name']
if not name_value:
continue
if not property_value.get('type'):

View File

@ -26,11 +26,13 @@ def get_youtube(actor_json: {}) -> str:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
name_value = property_value['name'].lower()
if isinstance(property_value['name'], str):
name_value = property_value['name'].lower()
elif property_value.get('schema:name'):
name_value = property_value['schema:name'].lower()
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'].lower()
if not name_value:
continue
if not string_contains(name_value, youtube_fieldnames):
@ -78,11 +80,13 @@ def set_youtube(actor_json: {}, youtube: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
name_value = property_value['name'].lower()
if isinstance(property_value['name'], str):
name_value = property_value['name'].lower()
elif property_value.get('schema:name'):
name_value = property_value['schema:name'].lower()
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'].lower()
if not name_value:
continue
if not property_value.get('type'):
@ -99,11 +103,13 @@ def set_youtube(actor_json: {}, youtube: str) -> None:
if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value))
continue
name_value = None
name_value: str = None
if property_value.get('name'):
name_value = property_value['name']
if isinstance(property_value['name'], str):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name']
if not name_value:
continue
if not property_value.get('type'):