mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
517740bbd6
commit
59840fc35e
62
utils.py
62
utils.py
|
@ -755,52 +755,36 @@ def getGenderFromBio(baseDir: str, actor: str, personCache: {},
|
||||||
pronounStr = translate['pronoun'].lower()
|
pronounStr = translate['pronoun'].lower()
|
||||||
else:
|
else:
|
||||||
pronounStr = 'pronoun'
|
pronounStr = 'pronoun'
|
||||||
|
actorJson = None
|
||||||
if personCache[actor].get('actor'):
|
if personCache[actor].get('actor'):
|
||||||
# is gender defined as a profile tag?
|
actorJson = personCache[actor]['actor']
|
||||||
if personCache[actor]['actor'].get('attachment'):
|
|
||||||
tagsList = personCache[actor]['actor']['attachment']
|
|
||||||
if isinstance(tagsList, list):
|
|
||||||
for tag in tagsList:
|
|
||||||
if not isinstance(tag, dict):
|
|
||||||
continue
|
|
||||||
if not tag.get('name') or not tag.get('value'):
|
|
||||||
continue
|
|
||||||
if tag['name'].lower() == \
|
|
||||||
translate['gender'].lower():
|
|
||||||
bioFound = tag['value']
|
|
||||||
break
|
|
||||||
elif tag['name'].lower().startswith(pronounStr):
|
|
||||||
bioFound = tag['value']
|
|
||||||
break
|
|
||||||
# if not then use the bio
|
|
||||||
if not bioFound and personCache[actor]['actor'].get('summary'):
|
|
||||||
bioFound = personCache[actor]['actor']['summary']
|
|
||||||
else:
|
else:
|
||||||
# Try to obtain from the cached actors
|
# Try to obtain from the cached actors
|
||||||
cachedActorFilename = \
|
cachedActorFilename = \
|
||||||
baseDir + '/cache/actors/' + (actor.replace('/', '#')) + '.json'
|
baseDir + '/cache/actors/' + (actor.replace('/', '#')) + '.json'
|
||||||
if os.path.isfile(cachedActorFilename):
|
if os.path.isfile(cachedActorFilename):
|
||||||
actorJson = loadJson(cachedActorFilename, 1)
|
actorJson = loadJson(cachedActorFilename, 1)
|
||||||
if actorJson:
|
if not actorJson:
|
||||||
# is gender defined as a profile tag?
|
return None
|
||||||
if actorJson.get('attachment'):
|
# is gender defined as a profile tag?
|
||||||
tagsList = actorJson['attachment']
|
if actorJson.get('attachment'):
|
||||||
if isinstance(tagsList, list):
|
tagsList = actorJson['attachment']
|
||||||
for tag in tagsList:
|
if isinstance(tagsList, list):
|
||||||
if not isinstance(tag, dict):
|
for tag in tagsList:
|
||||||
continue
|
if not isinstance(tag, dict):
|
||||||
if not tag.get('name') or not tag.get('value'):
|
continue
|
||||||
continue
|
if not tag.get('name') or not tag.get('value'):
|
||||||
if tag['name'].lower() == \
|
continue
|
||||||
translate['gender'].lower():
|
if tag['name'].lower() == \
|
||||||
bioFound = tag['value']
|
translate['gender'].lower():
|
||||||
break
|
bioFound = tag['value']
|
||||||
elif tag['name'].lower().startswith(pronounStr):
|
break
|
||||||
bioFound = tag['value']
|
elif tag['name'].lower().startswith(pronounStr):
|
||||||
break
|
bioFound = tag['value']
|
||||||
# if not then use the bio
|
break
|
||||||
if not bioFound and actorJson.get('summary'):
|
# if not then use the bio
|
||||||
bioFound = actorJson['summary']
|
if not bioFound and actorJson.get('summary'):
|
||||||
|
bioFound = actorJson['summary']
|
||||||
if not bioFound:
|
if not bioFound:
|
||||||
return None
|
return None
|
||||||
gender = 'They/Them'
|
gender = 'They/Them'
|
||||||
|
|
Loading…
Reference in New Issue