Get hashtag categories only when needed

main
Bob Mottram 2022-04-24 19:15:25 +01:00
parent 726447e1cb
commit b8b9f9f2fc
1 changed files with 1 additions and 2 deletions

View File

@ -227,8 +227,6 @@ def store_hash_tags(base_dir: str, nickname: str, domain: str,
print('Creating tags directory') print('Creating tags directory')
os.mkdir(tags_dir) os.mkdir(tags_dir)
hashtag_categories = get_hashtag_categories(base_dir)
hashtags_ctr = 0 hashtags_ctr = 0
for tag in post_json_object['object']['tag']: for tag in post_json_object['object']['tag']:
if not tag.get('type'): if not tag.get('type'):
@ -280,6 +278,7 @@ def store_hash_tags(base_dir: str, nickname: str, domain: str,
# 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):
hashtag_categories = get_hashtag_categories(base_dir)
category_str = \ category_str = \
guess_hashtag_category(tag_name, hashtag_categories) guess_hashtag_category(tag_name, hashtag_categories)
if category_str: if category_str: