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): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str): if isinstance(property_value['name'], str):
name_value = property_value['name'] 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): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str): if isinstance(property_value['name'], str):
name_value = property_value['name'] 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): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str): if isinstance(property_value['name'], str):
name_value = property_value['name'].lower() 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): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str): if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']

View File

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

View File

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

View File

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

View File

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

8
ssb.py
View File

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

12
tox.py
View File

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

View File

@ -181,10 +181,12 @@ def get_actor_languages_list(actor_json: {}) -> []:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
@ -1389,8 +1391,10 @@ def get_gender_from_bio(base_dir: str, actor: str, person_cache: {},
continue continue
name_value = None name_value = None
if tag.get('name'): if tag.get('name'):
if isinstance(tag['name'], str):
name_value = tag['name'] name_value = tag['name']
if tag.get('schema:name'): if tag.get('schema:name'):
if isinstance(tag['schema:name'], str):
name_value = tag['schema:name'] name_value = tag['schema:name']
if not name_value: if not name_value:
continue continue
@ -2868,13 +2872,15 @@ def get_actor_property_url(actor_json: {}, property_name: str) -> str:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: Actor attachment is not dict: " + str(property_value)) print("WARN: Actor attachment is not dict: " + str(property_value))
continue continue
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue

View File

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

View File

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

12
xmpp.py
View File

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

View File

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