mirror of https://gitlab.com/bashrc2/epicyon
Less indentation
parent
1bc643d34f
commit
4dafad931f
107
newswire.py
107
newswire.py
|
@ -1640,60 +1640,65 @@ def _add_account_blogs_to_newswire(base_dir: str, nickname: str, domain: str,
|
||||||
ctr = 0
|
ctr = 0
|
||||||
while post_filename:
|
while post_filename:
|
||||||
post_filename = fp_index.readline()
|
post_filename = fp_index.readline()
|
||||||
if post_filename:
|
if not post_filename:
|
||||||
# if this is a full path then remove the directories
|
ctr += 1
|
||||||
if '/' in post_filename:
|
if ctr >= max_blogs_per_account:
|
||||||
post_filename = post_filename.split('/')[-1]
|
break
|
||||||
|
continue
|
||||||
|
|
||||||
# filename of the post without any extension or path
|
# if this is a full path then remove the directories
|
||||||
# This should also correspond to any index entry in
|
if '/' in post_filename:
|
||||||
# the posts cache
|
post_filename = post_filename.split('/')[-1]
|
||||||
post_url = remove_eol(post_filename)
|
|
||||||
post_url = post_url.replace('.json', '').strip()
|
|
||||||
|
|
||||||
# read the post from file
|
# filename of the post without any extension or path
|
||||||
full_post_filename = \
|
# This should also correspond to any index entry in
|
||||||
locate_post(base_dir, nickname,
|
# the posts cache
|
||||||
domain, post_url, False)
|
post_url = remove_eol(post_filename)
|
||||||
if not full_post_filename:
|
post_url = post_url.replace('.json', '').strip()
|
||||||
print('Unable to locate post for newswire ' + post_url)
|
|
||||||
ctr += 1
|
|
||||||
if ctr >= max_blogs_per_account:
|
|
||||||
break
|
|
||||||
continue
|
|
||||||
|
|
||||||
post_json_object = None
|
# read the post from file
|
||||||
if full_post_filename:
|
full_post_filename = \
|
||||||
post_json_object = load_json(full_post_filename)
|
locate_post(base_dir, nickname,
|
||||||
if _is_newswire_blog_post(post_json_object):
|
domain, post_url, False)
|
||||||
published = post_json_object['object']['published']
|
if not full_post_filename:
|
||||||
published = published.replace('T', ' ')
|
print('Unable to locate post for newswire ' + post_url)
|
||||||
published = published.replace('Z', '+00:00')
|
ctr += 1
|
||||||
votes = []
|
if ctr >= max_blogs_per_account:
|
||||||
if os.path.isfile(full_post_filename + '.votes'):
|
break
|
||||||
votes = load_json(full_post_filename + '.votes')
|
continue
|
||||||
content = \
|
|
||||||
get_base_content_from_post(post_json_object,
|
post_json_object = None
|
||||||
system_language)
|
if full_post_filename:
|
||||||
description = first_paragraph_from_string(content)
|
post_json_object = load_json(full_post_filename)
|
||||||
description = remove_html(description)
|
if _is_newswire_blog_post(post_json_object):
|
||||||
tags_from_post = \
|
published = post_json_object['object']['published']
|
||||||
_get_hashtags_from_post(post_json_object)
|
published = published.replace('T', ' ')
|
||||||
summary = post_json_object['object']['summary']
|
published = published.replace('Z', '+00:00')
|
||||||
url2 = post_json_object['object']['url']
|
votes = []
|
||||||
url_str = get_url_from_post(url2)
|
if os.path.isfile(full_post_filename + '.votes'):
|
||||||
url3 = remove_html(url_str)
|
votes = load_json(full_post_filename + '.votes')
|
||||||
fediverse_handle = ''
|
content = \
|
||||||
extra_links = []
|
get_base_content_from_post(post_json_object,
|
||||||
_add_newswire_dict_entry(base_dir,
|
system_language)
|
||||||
newswire, published,
|
description = first_paragraph_from_string(content)
|
||||||
summary, url3,
|
description = remove_html(description)
|
||||||
votes, full_post_filename,
|
tags_from_post = \
|
||||||
description, moderated, False,
|
_get_hashtags_from_post(post_json_object)
|
||||||
tags_from_post,
|
summary = post_json_object['object']['summary']
|
||||||
max_tags, session, debug,
|
url2 = post_json_object['object']['url']
|
||||||
None, system_language,
|
url_str = get_url_from_post(url2)
|
||||||
fediverse_handle, extra_links)
|
url3 = remove_html(url_str)
|
||||||
|
fediverse_handle = ''
|
||||||
|
extra_links = []
|
||||||
|
_add_newswire_dict_entry(base_dir,
|
||||||
|
newswire, published,
|
||||||
|
summary, url3,
|
||||||
|
votes, full_post_filename,
|
||||||
|
description, moderated, False,
|
||||||
|
tags_from_post,
|
||||||
|
max_tags, session, debug,
|
||||||
|
None, system_language,
|
||||||
|
fediverse_handle, extra_links)
|
||||||
|
|
||||||
ctr += 1
|
ctr += 1
|
||||||
if ctr >= max_blogs_per_account:
|
if ctr >= max_blogs_per_account:
|
||||||
|
|
Loading…
Reference in New Issue