diff --git a/utils.py b/utils.py index 8fb392e9..414f46bd 100644 --- a/utils.py +++ b/utils.py @@ -23,11 +23,18 @@ def getHashtagCategory(baseDir: str, hashtag: str) -> str: """Returns the category for the hashtag """ categoryFilename = baseDir + '/tags/' + hashtag + '.category' - if os.path.isfile(categoryFilename): - with open(categoryFilename, 'r') as fp: - categoryStr = fp.read() - if categoryStr: - return categoryStr + if not os.path.isfile(categoryFilename): + categoryFilename = baseDir + '/tags/' + hashtag.title() + '.category' + if not os.path.isfile(categoryFilename): + categoryFilename = \ + baseDir + '/tags/' + hashtag.upper() + '.category' + if not os.path.isfile(categoryFilename): + return '' + + with open(categoryFilename, 'r') as fp: + categoryStr = fp.read() + if categoryStr: + return categoryStr return ''