mirror of https://gitlab.com/bashrc2/epicyon
Less indentation
parent
2d0a53bd29
commit
edc5a8c463
47
utils.py
47
utils.py
|
@ -1895,11 +1895,12 @@ def get_nickname_from_actor(actor: str) -> str:
|
||||||
actor = actor[1:]
|
actor = actor[1:]
|
||||||
users_paths = get_user_paths()
|
users_paths = get_user_paths()
|
||||||
for possible_path in users_paths:
|
for possible_path in users_paths:
|
||||||
if possible_path in actor:
|
if possible_path not in actor:
|
||||||
nick_str = actor.split(possible_path)[1].replace('@', '')
|
continue
|
||||||
if '/' not in nick_str:
|
nick_str = actor.split(possible_path)[1].replace('@', '')
|
||||||
return nick_str
|
if '/' not in nick_str:
|
||||||
return nick_str.split('/')[0]
|
return nick_str
|
||||||
|
return nick_str.split('/')[0]
|
||||||
if '/@/' not in actor:
|
if '/@/' not in actor:
|
||||||
if '/@' in actor:
|
if '/@' in actor:
|
||||||
# https://domain/@nick
|
# https://domain/@nick
|
||||||
|
@ -1951,11 +1952,12 @@ def get_domain_from_actor(actor: str) -> (str, int):
|
||||||
prefixes = get_protocol_prefixes()
|
prefixes = get_protocol_prefixes()
|
||||||
users_paths = get_user_paths()
|
users_paths = get_user_paths()
|
||||||
for possible_path in users_paths:
|
for possible_path in users_paths:
|
||||||
if possible_path in actor:
|
if possible_path not in actor:
|
||||||
domain = actor.split(possible_path)[0]
|
continue
|
||||||
for prefix in prefixes:
|
domain = actor.split(possible_path)[0]
|
||||||
domain = domain.replace(prefix, '')
|
for prefix in prefixes:
|
||||||
break
|
domain = domain.replace(prefix, '')
|
||||||
|
break
|
||||||
if '/@' in actor and '/@/' not in actor:
|
if '/@' in actor and '/@/' not in actor:
|
||||||
domain = actor.split('/@')[0]
|
domain = actor.split('/@')[0]
|
||||||
for prefix in prefixes:
|
for prefix in prefixes:
|
||||||
|
@ -2480,10 +2482,11 @@ def _delete_post_remove_replies(base_dir: str, nickname: str, domain: str,
|
||||||
reply_file = locate_post(base_dir, nickname, domain, reply_id)
|
reply_file = locate_post(base_dir, nickname, domain, reply_id)
|
||||||
if not reply_file:
|
if not reply_file:
|
||||||
continue
|
continue
|
||||||
if os.path.isfile(reply_file):
|
if not os.path.isfile(reply_file):
|
||||||
delete_post(base_dir, http_prefix,
|
continue
|
||||||
nickname, domain, reply_file, debug,
|
delete_post(base_dir, http_prefix,
|
||||||
recent_posts_cache, manual)
|
nickname, domain, reply_file, debug,
|
||||||
|
recent_posts_cache, manual)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: _delete_post_remove_replies unable to read ' +
|
print('EX: _delete_post_remove_replies unable to read ' +
|
||||||
replies_filename)
|
replies_filename)
|
||||||
|
@ -3425,13 +3428,15 @@ def undo_likes_collection_entry(recent_posts_cache: {},
|
||||||
total_items = obj['likes']['totalItems']
|
total_items = obj['likes']['totalItems']
|
||||||
item_found = False
|
item_found = False
|
||||||
for like_item in obj['likes']['items']:
|
for like_item in obj['likes']['items']:
|
||||||
if like_item.get('actor'):
|
if not like_item.get('actor'):
|
||||||
if like_item['actor'] == actor:
|
continue
|
||||||
if debug:
|
if like_item['actor'] != actor:
|
||||||
print('DEBUG: like was removed for ' + actor)
|
continue
|
||||||
obj['likes']['items'].remove(like_item)
|
if debug:
|
||||||
item_found = True
|
print('DEBUG: like was removed for ' + actor)
|
||||||
break
|
obj['likes']['items'].remove(like_item)
|
||||||
|
item_found = True
|
||||||
|
break
|
||||||
if not item_found:
|
if not item_found:
|
||||||
return
|
return
|
||||||
if total_items == 1:
|
if total_items == 1:
|
||||||
|
|
Loading…
Reference in New Issue