Skip to content

Commit 7c5bfa5

Browse files
committed
Fix keyword-based search (#323)
* Fixes directories handling in git-based repos * Fixes a minor bug in tldr-adapter
1 parent 46d1a5f commit 7c5bfa5

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/adapter/git_adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def _get_page(self, topic, request_options=None):
4343
self._cheatsheet_files_prefix,
4444
topic)
4545

46-
if os.path.exists(filename):
46+
if os.path.exists(filename) and not os.path.isdir(filename):
4747
answer = self._format_page(open(filename, 'r').read())
4848
else:
4949
# though it should not happen

lib/adapter/tldr.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,16 @@ def _get_page(self, topic, request_options=None):
7373
and as soon as anything is found, format and return it.
7474
"""
7575

76-
search_order = ['common', 'linux', 'osx', 'sunos', 'windows']
76+
search_order = ['common', 'linux', 'osx', 'sunos', 'windows', "android"]
7777
local_rep = self.local_repository_location()
7878
ext = self._cheatsheet_files_extension
7979

8080
filename = None
8181
for subdir in search_order:
82-
filename = os.path.join(
82+
_filename = os.path.join(
8383
local_rep, 'pages', subdir, "%s%s" % (topic, ext))
84-
if os.path.exists(filename):
84+
if os.path.exists(_filename):
85+
filename = _filename
8586
break
8687

8788
if filename:

0 commit comments

Comments
 (0)