From 575054760f31670127cb3a0d8043200676fcacaa Mon Sep 17 00:00:00 2001 From: Luciano Strika Date: Sat, 14 Jul 2018 00:42:30 -0300 Subject: [PATCH] refactor tldr_update so it fits in two lines. abrstracted logic away into a function. --- lib/get_answer.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/get_answer.py b/lib/get_answer.py index 2fc4a9a..d9d9499 100644 --- a/lib/get_answer.py +++ b/lib/get_answer.py @@ -56,13 +56,13 @@ INTERNAL_TOPICS = [ ':share', ] +def _get_filenames(): + return [os.path.split(topic)[1] for topic in glob.glob(PATH_TLDR_PAGES)] + + def _update_tldr_topics(): - answer = [] - for topic in glob.glob(PATH_TLDR_PAGES): - _, filename = os.path.split(topic) - if filename.endswith('.md'): - answer.append(filename[:-3]) - return answer + return [ filename[:-3] for filename in _get_filenames() if filename.endswith('.md') ] + TLDR_TOPICS = _update_tldr_topics() def _update_cheat_topics():