From c3ce17cb6bd1565e06fc77afab5147bc3d0dc998 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 3 Dec 2020 12:46:56 +0000 Subject: [PATCH] Try different cases when setting title --- utils.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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 ''