1
0
mirror of https://github.com/chubin/cheat.sh.git synced 2026-06-20 21:26:44 +02:00

saw a common pattern and cleaned the code for cheat topics updater function

This commit is contained in:
Luciano Strika
2018-07-14 00:45:35 -03:00
parent 575054760f
commit ec6f7d1337
+5 -8
View File
@@ -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():