mirror of https://github.com/cheat/cheat.git
Recurse subdirectories within a cheat dir.
This lets you share cheats more easily with others. For example, within ~/.cheat I can have one subfolder of public cheats, one subfolder of private within-company cheats, and one I've cloned from a friend on github.
This commit is contained in:
parent
ac4920aaee
commit
bdeed4ab84
18
cheat
18
cheat
|
@ -62,11 +62,19 @@ def cheat_directories():
|
||||||
def cheat_files(cheat_directories):
|
def cheat_files(cheat_directories):
|
||||||
"Assembles a dictionary of cheatsheets found in the above directories."
|
"Assembles a dictionary of cheatsheets found in the above directories."
|
||||||
cheats = {}
|
cheats = {}
|
||||||
for cheat_dir in reversed(cheat_directories):
|
queue = cheat_directories[:]
|
||||||
cheats.update(dict([(cheat, cheat_dir)
|
while queue:
|
||||||
for cheat in os.listdir(cheat_dir)
|
cheat_dir = queue.pop()
|
||||||
if not cheat.startswith('.')
|
for cheat in os.listdir(cheat_dir):
|
||||||
and not cheat.startswith('__')]))
|
if not cheat.startswith('.') and not cheat.startswith('__'):
|
||||||
|
cheat_path = os.path.join(cheat_dir, cheat)
|
||||||
|
if os.path.isdir(cheat_path):
|
||||||
|
# recurse subdirectory
|
||||||
|
sub_dir = os.path.join(cheat_dir, cheat)
|
||||||
|
queue.append(sub_dir)
|
||||||
|
else:
|
||||||
|
cheats[cheat] = cheat_dir
|
||||||
|
|
||||||
return cheats
|
return cheats
|
||||||
|
|
||||||
def edit_cheatsheet(cheat, cheatsheets):
|
def edit_cheatsheet(cheat, cheatsheets):
|
||||||
|
|
Loading…
Reference in New Issue