mirror of https://gitlab.com/bashrc2/epicyon
Supporting alternative name and value properties in attachments
parent
471c9d4a72
commit
ed9854de10
21
pgp.py
21
pgp.py
|
@ -238,7 +238,11 @@ def set_pgp_pub_key(actor_json: {}, pgp_pub_key: str) -> None:
|
||||||
continue
|
continue
|
||||||
if not property_value['type'].endswith('PropertyValue'):
|
if not property_value['type'].endswith('PropertyValue'):
|
||||||
continue
|
continue
|
||||||
property_value['value'] = pgp_pub_key
|
prop_value_name, _ = \
|
||||||
|
get_attachment_property_value(property_value)
|
||||||
|
if not prop_value_name:
|
||||||
|
continue
|
||||||
|
property_value[prop_value_name] = pgp_pub_key
|
||||||
return
|
return
|
||||||
|
|
||||||
newpgp_pub_key = {
|
newpgp_pub_key = {
|
||||||
|
@ -297,7 +301,11 @@ def set_pgp_fingerprint(actor_json: {}, fingerprint: str) -> None:
|
||||||
continue
|
continue
|
||||||
if not property_value['type'].endswith('PropertyValue'):
|
if not property_value['type'].endswith('PropertyValue'):
|
||||||
continue
|
continue
|
||||||
property_value['value'] = fingerprint.strip()
|
prop_value_name, _ = \
|
||||||
|
get_attachment_property_value(property_value)
|
||||||
|
if not prop_value_name:
|
||||||
|
continue
|
||||||
|
property_value[prop_value_name] = fingerprint.strip()
|
||||||
return
|
return
|
||||||
|
|
||||||
newpgp_fingerprint = {
|
newpgp_fingerprint = {
|
||||||
|
@ -509,12 +517,13 @@ def _get_pgp_public_key_from_actor(signing_priv_key_pem: str,
|
||||||
for tag in actor_json['attachment']:
|
for tag in actor_json['attachment']:
|
||||||
if not isinstance(tag, dict):
|
if not isinstance(tag, dict):
|
||||||
continue
|
continue
|
||||||
if not tag.get('value'):
|
prop_value_name, _ = get_attachment_property_value(tag)
|
||||||
|
if not prop_value_name:
|
||||||
continue
|
continue
|
||||||
if not isinstance(tag['value'], str):
|
if not isinstance(tag[prop_value_name], str):
|
||||||
continue
|
continue
|
||||||
if contains_pgp_public_key(tag['value']):
|
if contains_pgp_public_key(tag[prop_value_name]):
|
||||||
return tag['value']
|
return tag[prop_value_name]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
26
utils.py
26
utils.py
|
@ -1106,14 +1106,22 @@ def get_gender_from_bio(base_dir: str, actor: str, person_cache: {},
|
||||||
for tag in tags_list:
|
for tag in tags_list:
|
||||||
if not isinstance(tag, dict):
|
if not isinstance(tag, dict):
|
||||||
continue
|
continue
|
||||||
if not tag.get('name') or not tag.get('value'):
|
name_value = None
|
||||||
|
if tag.get('name'):
|
||||||
|
name_value = tag['name']
|
||||||
|
if tag.get('schema:name'):
|
||||||
|
name_value = tag['schema:name']
|
||||||
|
if not name_value:
|
||||||
continue
|
continue
|
||||||
if tag['name'].lower() == \
|
prop_value_name, _ = get_attachment_property_value(tag)
|
||||||
|
if not prop_value_name:
|
||||||
|
continue
|
||||||
|
if name_value.lower() == \
|
||||||
translate['gender'].lower():
|
translate['gender'].lower():
|
||||||
bio_found = tag['value']
|
bio_found = name_value
|
||||||
break
|
break
|
||||||
if tag['name'].lower().startswith(pronoun_str):
|
if name_value.lower().startswith(pronoun_str):
|
||||||
bio_found = tag['value']
|
bio_found = name_value
|
||||||
break
|
break
|
||||||
# the field name could be anything,
|
# the field name could be anything,
|
||||||
# just look at the value
|
# just look at the value
|
||||||
|
@ -1121,9 +1129,13 @@ def get_gender_from_bio(base_dir: str, actor: str, person_cache: {},
|
||||||
for tag in tags_list:
|
for tag in tags_list:
|
||||||
if not isinstance(tag, dict):
|
if not isinstance(tag, dict):
|
||||||
continue
|
continue
|
||||||
if not tag.get('name') or not tag.get('value'):
|
if not tag.get('name') and not tag.get('schema:name'):
|
||||||
continue
|
continue
|
||||||
gender = _gender_from_string(translate, tag['value'])
|
prop_value_name, _ = get_attachment_property_value(tag)
|
||||||
|
if not prop_value_name:
|
||||||
|
continue
|
||||||
|
gender = \
|
||||||
|
_gender_from_string(translate, tag[prop_value_name])
|
||||||
if gender:
|
if gender:
|
||||||
return gender
|
return gender
|
||||||
# if not then use the bio
|
# if not then use the bio
|
||||||
|
|
|
@ -802,11 +802,16 @@ def html_header_with_person_markup(css_filename: str, instance_title: str,
|
||||||
)
|
)
|
||||||
for attach_json in actor_json['attachment']:
|
for attach_json in actor_json['attachment']:
|
||||||
if not attach_json.get('name'):
|
if not attach_json.get('name'):
|
||||||
|
if not attach_json.get('schema:name'):
|
||||||
continue
|
continue
|
||||||
if not attach_json.get('value'):
|
prop_value_name, _ = get_attachment_property_value(attach_json)
|
||||||
|
if not prop_value_name:
|
||||||
continue
|
continue
|
||||||
|
if attach_json.get('name'):
|
||||||
name = attach_json['name'].lower()
|
name = attach_json['name'].lower()
|
||||||
value = attach_json['value']
|
else:
|
||||||
|
name = attach_json['schema:name'].lower()
|
||||||
|
value = attach_json[prop_value_name]
|
||||||
for og_tag in og_tags:
|
for og_tag in og_tags:
|
||||||
if name != og_tag:
|
if name != og_tag:
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue