From ec6f7d133753eba81ce015945ff25b49fa2294d4 Mon Sep 17 00:00:00 2001 From: Luciano Strika Date: Sat, 14 Jul 2018 00:45:35 -0300 Subject: [PATCH] saw a common pattern and cleaned the code for cheat topics updater function --- lib/get_answer.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/get_answer.py b/lib/get_answer.py index d9d9499..2d8d05e 100644 --- a/lib/get_answer.py +++ b/lib/get_answer.py @@ -56,21 +56,18 @@ INTERNAL_TOPICS = [ ':share', ] -def _get_filenames(): - return [os.path.split(topic)[1] for topic in glob.glob(PATH_TLDR_PAGES)] +def _get_filenames(path): + return [os.path.split(topic)[1] for topic in glob.glob(path)] def _update_tldr_topics(): - return [ filename[:-3] for filename in _get_filenames() if filename.endswith('.md') ] + return [ filename[:-3] for filename in _get_filenames(PATH_TLDR_PAGES) if filename.endswith('.md') ] TLDR_TOPICS = _update_tldr_topics() def _update_cheat_topics(): - answer = [] - for topic in glob.glob(PATH_CHEAT_PAGES): - _, filename = os.path.split(topic) - answer.append(filename) - return answer + return _get_filenames(PATH_CHEAT_PAGES) + CHEAT_TOPICS = _update_cheat_topics() def _update_cheat_sheets_topics():