Less indentation

main
Bob Mottram 2025-06-02 12:59:03 +01:00
parent f8bcd406c8
commit dcc112637c
1 changed files with 20 additions and 17 deletions

View File

@ -1085,23 +1085,26 @@ def _update_hashtags_index(base_dir: str, tag: {}, new_post_id: str,
except OSError: except OSError:
print('EX: _update_hashtags_index unable to write tags file ' + print('EX: _update_hashtags_index unable to write tags file ' +
tags_filename) tags_filename)
else: return
# prepend to tags index file
if not text_in_file(new_post_id, tags_filename): if text_in_file(new_post_id, tags_filename):
days_diff = date_utcnow() - date_epoch() return
days_since_epoch = days_diff.days
tag_line = \ # prepend to tags index file
str(days_since_epoch) + ' ' + nickname + ' ' + \ days_diff = date_utcnow() - date_epoch()
new_post_id + '\n' days_since_epoch = days_diff.days
try: tag_line = \
with open(tags_filename, 'r+', encoding='utf-8') as fp_tags: str(days_since_epoch) + ' ' + nickname + ' ' + \
content = fp_tags.read() new_post_id + '\n'
if tag_line not in content: try:
fp_tags.seek(0, 0) with open(tags_filename, 'r+', encoding='utf-8') as fp_tags:
fp_tags.write(tag_line + content) content = fp_tags.read()
except OSError as ex: if tag_line not in content:
print('EX: Failed to write entry to tags file ' + fp_tags.seek(0, 0)
tags_filename + ' ' + str(ex)) fp_tags.write(tag_line + content)
except OSError as ex:
print('EX: Failed to write entry to tags file ' +
tags_filename + ' ' + str(ex))
def _add_schedule_post(base_dir: str, nickname: str, domain: str, def _add_schedule_post(base_dir: str, nickname: str, domain: str,