1
1
mirror of https://github.com/chubin/cheat.sh.git synced 2024-11-22 01:40:48 +03:00

Fix keyword-based search (#323)

* Fixes directories handling in git-based repos
* Fixes a minor bug in tldr-adapter
This commit is contained in:
Igor Chubin 2022-04-17 05:54:37 +00:00
parent 60cc9faf39
commit 9ab558cc98
2 changed files with 5 additions and 4 deletions

View File

@ -43,7 +43,7 @@ class RepositoryAdapter(Adapter):
self._cheatsheet_files_prefix,
topic)
if os.path.exists(filename):
if os.path.exists(filename) and not os.path.isdir(filename):
answer = self._format_page(open(filename, 'r').read())
else:
# though it should not happen

View File

@ -73,15 +73,16 @@ class Tldr(GitRepositoryAdapter):
and as soon as anything is found, format and return it.
"""
search_order = ['common', 'linux', 'osx', 'sunos', 'windows']
search_order = ['common', 'linux', 'osx', 'sunos', 'windows', "android"]
local_rep = self.local_repository_location()
ext = self._cheatsheet_files_extension
filename = None
for subdir in search_order:
filename = os.path.join(
_filename = os.path.join(
local_rep, 'pages', subdir, "%s%s" % (topic, ext))
if os.path.exists(filename):
if os.path.exists(_filename):
filename = _filename
break
if filename: