mirror of https://gitlab.com/bashrc2/epicyon
Only update category if hashtag was added
parent
3c17749dae
commit
726447e1cb
10
inbox.py
10
inbox.py
|
@ -249,11 +249,12 @@ def store_hash_tags(base_dir: str, nickname: str, domain: str,
|
||||||
days_since_epoch = days_diff.days
|
days_since_epoch = days_diff.days
|
||||||
tag_line = \
|
tag_line = \
|
||||||
str(days_since_epoch) + ' ' + nickname + ' ' + post_url + '\n'
|
str(days_since_epoch) + ' ' + nickname + ' ' + post_url + '\n'
|
||||||
hashtags_ctr += 1
|
hashtag_added = False
|
||||||
if not os.path.isfile(tags_filename):
|
if not os.path.isfile(tags_filename):
|
||||||
try:
|
try:
|
||||||
with open(tags_filename, 'w+') as tags_file:
|
with open(tags_filename, 'w+') as tags_file:
|
||||||
tags_file.write(tag_line)
|
tags_file.write(tag_line)
|
||||||
|
hashtag_added = True
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: unable to write ' + tags_filename)
|
print('EX: unable to write ' + tags_filename)
|
||||||
else:
|
else:
|
||||||
|
@ -268,17 +269,22 @@ def store_hash_tags(base_dir: str, nickname: str, domain: str,
|
||||||
try:
|
try:
|
||||||
with open(tags_filename, 'w+') as tags_file:
|
with open(tags_filename, 'w+') as tags_file:
|
||||||
tags_file.write(content)
|
tags_file.write(content)
|
||||||
|
hashtag_added = True
|
||||||
except OSError as ex:
|
except OSError as ex:
|
||||||
print('EX: Failed to write entry to tags file ' +
|
print('EX: Failed to write entry to tags file ' +
|
||||||
tags_filename + ' ' + str(ex))
|
tags_filename + ' ' + str(ex))
|
||||||
|
|
||||||
|
if hashtag_added:
|
||||||
|
hashtags_ctr += 1
|
||||||
|
|
||||||
# automatically assign a category to the tag if possible
|
# automatically assign a category to the tag if possible
|
||||||
category_filename = tags_dir + '/' + tag_name + '.category'
|
category_filename = tags_dir + '/' + tag_name + '.category'
|
||||||
if not os.path.isfile(category_filename):
|
if not os.path.isfile(category_filename):
|
||||||
category_str = \
|
category_str = \
|
||||||
guess_hashtag_category(tag_name, hashtag_categories)
|
guess_hashtag_category(tag_name, hashtag_categories)
|
||||||
if category_str:
|
if category_str:
|
||||||
set_hashtag_category(base_dir, tag_name, category_str, False)
|
set_hashtag_category(base_dir, tag_name,
|
||||||
|
category_str, False)
|
||||||
|
|
||||||
# if some hashtags were found then recalculate the swarm
|
# if some hashtags were found then recalculate the swarm
|
||||||
# ready for later display
|
# ready for later display
|
||||||
|
|
Loading…
Reference in New Issue