Check property types

main
bashrc 2026-05-05 13:03:39 +01:00
parent fc8885d679
commit 3d7cf796be
1 changed files with 12 additions and 8 deletions

12
art.py
View File

@ -67,7 +67,7 @@ def get_art_site_url(actor_json: {}) -> str:
get_attachment_property_value(property_value)
if not prop_value_name:
continue
art_text = remove_html(property_value[prop_value_name])
art_text: str = remove_html(property_value[prop_value_name])
if not string_contains(art_text, art_sites):
continue
if not resembles_url(art_text):
@ -87,15 +87,17 @@ def set_art_site_url(actor_json: {}, art_site_url: str) -> None:
actor_json['attachment']: list[dict] = []
# remove any existing value
property_found = None
property_found: dict = None
for property_value in actor_json['attachment']:
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()
elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'].lower()
if not name_value:
continue
@ -113,10 +115,12 @@ def set_art_site_url(actor_json: {}, art_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'):
if isinstance(property_value['name'], str):
name_value = property_value['name']
elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name']
if not name_value:
continue