Less indentation

merge-requests/30/head
Bob Mottram 2024-07-15 20:44:46 +01:00
parent ceaaa8aec0
commit 1bc643d34f
1 changed files with 86 additions and 78 deletions

View File

@ -990,27 +990,29 @@ def _xml1str_to_dict(base_dir: str, domain: str, xml_str: str,
unique_string_identifier = title + ' ' + link unique_string_identifier = title + ' ' + link
pub_date_str = parse_feed_date(pub_date, unique_string_identifier) pub_date_str = parse_feed_date(pub_date, unique_string_identifier)
if pub_date_str: if not pub_date_str:
if _valid_feed_date(pub_date_str): continue
post_filename = '' if not _valid_feed_date(pub_date_str):
votes_status = [] continue
podcast_properties = \ post_filename = ''
xml_podcast_to_dict(base_dir, rss_item, xml_str) votes_status = []
if podcast_properties: podcast_properties = \
podcast_properties['linkMimeType'] = link_mime_type xml_podcast_to_dict(base_dir, rss_item, xml_str)
fediverse_handle = '' if podcast_properties:
extra_links = [] podcast_properties['linkMimeType'] = link_mime_type
_add_newswire_dict_entry(base_dir, fediverse_handle = ''
result, pub_date_str, extra_links = []
title, link, _add_newswire_dict_entry(base_dir,
votes_status, post_filename, result, pub_date_str,
description, moderated, title, link,
mirrored, [], 32, session, debug, votes_status, post_filename,
podcast_properties, system_language, description, moderated,
fediverse_handle, extra_links) mirrored, [], 32, session, debug,
post_ctr += 1 podcast_properties, system_language,
if post_ctr >= max_posts_per_source: fediverse_handle, extra_links)
break post_ctr += 1
if post_ctr >= max_posts_per_source:
break
if post_ctr > 0: if post_ctr > 0:
print('Added ' + str(post_ctr) + ' rss 1.0 feed items to newswire') print('Added ' + str(post_ctr) + ' rss 1.0 feed items to newswire')
return result return result
@ -1146,25 +1148,27 @@ def _atom_feed_to_dict(base_dir: str, domain: str, xml_str: str,
unique_string_identifier = title + ' ' + link unique_string_identifier = title + ' ' + link
pub_date_str = parse_feed_date(pub_date, unique_string_identifier) pub_date_str = parse_feed_date(pub_date, unique_string_identifier)
if pub_date_str: if not pub_date_str:
if _valid_feed_date(pub_date_str): continue
post_filename = '' if not _valid_feed_date(pub_date_str):
votes_status = [] continue
podcast_properties = \ post_filename = ''
xml_podcast_to_dict(base_dir, atom_item, xml_str) votes_status = []
if podcast_properties: podcast_properties = \
podcast_properties['linkMimeType'] = link_mime_type xml_podcast_to_dict(base_dir, atom_item, xml_str)
_add_newswire_dict_entry(base_dir, if podcast_properties:
result, pub_date_str, podcast_properties['linkMimeType'] = link_mime_type
title, link, _add_newswire_dict_entry(base_dir,
votes_status, post_filename, result, pub_date_str,
description, moderated, title, link,
mirrored, [], 32, session, debug, votes_status, post_filename,
podcast_properties, system_language, description, moderated,
fediverse_handle, extra_links) mirrored, [], 32, session, debug,
post_ctr += 1 podcast_properties, system_language,
if post_ctr >= max_posts_per_source: fediverse_handle, extra_links)
break post_ctr += 1
if post_ctr >= max_posts_per_source:
break
if post_ctr > 0: if post_ctr > 0:
print('Added ' + str(post_ctr) + ' atom feed items to newswire') print('Added ' + str(post_ctr) + ' atom feed items to newswire')
return result return result
@ -1266,23 +1270,25 @@ def _json_feed_v1to_dict(base_dir: str, xml_str: str,
unique_string_identifier = title + ' ' + link unique_string_identifier = title + ' ' + link
pub_date_str = parse_feed_date(pub_date, unique_string_identifier) pub_date_str = parse_feed_date(pub_date, unique_string_identifier)
if pub_date_str: if not pub_date_str:
if _valid_feed_date(pub_date_str): continue
post_filename = '' if not _valid_feed_date(pub_date_str):
votes_status = [] continue
fediverse_handle = '' post_filename = ''
extra_links = [] votes_status = []
_add_newswire_dict_entry(base_dir, fediverse_handle = ''
result, pub_date_str, extra_links = []
title, link, _add_newswire_dict_entry(base_dir,
votes_status, post_filename, result, pub_date_str,
description, moderated, title, link,
mirrored, [], 32, session, debug, votes_status, post_filename,
None, system_language, description, moderated,
fediverse_handle, extra_links) mirrored, [], 32, session, debug,
post_ctr += 1 None, system_language,
if post_ctr >= max_posts_per_source: fediverse_handle, extra_links)
break post_ctr += 1
if post_ctr >= max_posts_per_source:
break
if post_ctr > 0: if post_ctr > 0:
print('Added ' + str(post_ctr) + print('Added ' + str(post_ctr) +
' json feed items to newswire') ' json feed items to newswire')
@ -1368,27 +1374,29 @@ def _atom_feed_yt_to_dict(base_dir: str, xml_str: str,
unique_string_identifier = title + ' ' + link unique_string_identifier = title + ' ' + link
pub_date_str = parse_feed_date(pub_date, unique_string_identifier) pub_date_str = parse_feed_date(pub_date, unique_string_identifier)
if pub_date_str: if not pub_date_str:
if _valid_feed_date(pub_date_str): continue
post_filename = '' if not _valid_feed_date(pub_date_str):
votes_status = [] continue
podcast_properties = \ post_filename = ''
xml_podcast_to_dict(base_dir, atom_item, xml_str) votes_status = []
if podcast_properties: podcast_properties = \
podcast_properties['linkMimeType'] = 'video/youtube' xml_podcast_to_dict(base_dir, atom_item, xml_str)
fediverse_handle = '' if podcast_properties:
extra_links = [] podcast_properties['linkMimeType'] = 'video/youtube'
_add_newswire_dict_entry(base_dir, fediverse_handle = ''
result, pub_date_str, extra_links = []
title, link, _add_newswire_dict_entry(base_dir,
votes_status, post_filename, result, pub_date_str,
description, moderated, mirrored, title, link,
[], 32, session, debug, votes_status, post_filename,
podcast_properties, system_language, description, moderated, mirrored,
fediverse_handle, extra_links) [], 32, session, debug,
post_ctr += 1 podcast_properties, system_language,
if post_ctr >= max_posts_per_source: fediverse_handle, extra_links)
break post_ctr += 1
if post_ctr >= max_posts_per_source:
break
if post_ctr > 0: if post_ctr > 0:
print('Added ' + str(post_ctr) + ' YouTube feed items to newswire') print('Added ' + str(post_ctr) + ' YouTube feed items to newswire')
return result return result