Less indentation

main
Bob Mottram 2024-08-05 11:04:05 +01:00
parent 0cb9a946b2
commit 37d7b7fbc3
1 changed files with 31 additions and 23 deletions

View File

@ -508,8 +508,10 @@ def get_language_from_post(post_json_object: {}, system_language: str,
if not this_post_json.get(content_type):
return system_language
map_dict = content_type + 'Map'
if this_post_json.get(map_dict):
if isinstance(this_post_json[map_dict], dict):
if not this_post_json.get(map_dict):
return system_language
if not isinstance(this_post_json[map_dict], dict):
return system_language
if this_post_json[map_dict].get(system_language):
sys_lang = this_post_json[map_dict][system_language]
if isinstance(sys_lang, str):
@ -4250,15 +4252,20 @@ def is_group_actor(base_dir: str, actor: str, person_cache: {},
debug: bool = False) -> bool:
"""Is the given actor a group?
"""
person_cache_actor = None
if person_cache:
if person_cache.get(actor):
if person_cache[actor].get('actor'):
if person_cache[actor]['actor'].get('type'):
if person_cache[actor]['actor']['type'] == 'Group':
person_cache_actor = person_cache[actor]['actor']
if person_cache_actor:
if person_cache_actor.get('type'):
if person_cache_actor['type'] == 'Group':
if debug:
print('Cached actor ' + actor + ' has Group type')
return True
return False
if debug:
print('Actor ' + actor + ' not in cache')
cached_actor_filename = \
@ -4984,7 +4991,8 @@ def get_quote_toot_url(post_json_object: str) -> str:
object_quote_url_fields = ('quoteUri', 'quoteUrl', 'quoteReply',
'toot:quoteReply', '_misskey_quote')
for fieldname in object_quote_url_fields:
if post_json_object['object'].get(fieldname):
if not post_json_object['object'].get(fieldname):
continue
quote_url = post_json_object['object'][fieldname]
if isinstance(quote_url, str):
if resembles_url(quote_url):