mirror of
https://github.com/cheat/cheat.git
synced 2025-09-01 09:38:29 +02:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
8677e0c35a | |||
afcaaafbe5 |
9
CONTRIBUTING.md
Normal file
9
CONTRIBUTING.md
Normal file
@ -0,0 +1,9 @@
|
||||
Contributing
|
||||
============
|
||||
If you would like to contribute cheetsheets or program functionality, please
|
||||
fork this repository, make your changes, and send me a pull request.
|
||||
|
||||
Python code show follow the standards laid out by [PEP 8][].
|
||||
|
||||
|
||||
[PEP 8]: http://legacy.python.org/dev/peps/pep-0008/
|
@ -38,7 +38,7 @@ from docopt import docopt
|
||||
|
||||
if __name__ == '__main__':
|
||||
# parse the command-line options
|
||||
options = docopt(__doc__, version='cheat 2.0.3')
|
||||
options = docopt(__doc__, version='cheat 2.0.5')
|
||||
|
||||
# list directories
|
||||
if options['--directories']:
|
||||
|
@ -2,6 +2,12 @@ from cheat import cheatsheets
|
||||
from cheat.utils import *
|
||||
import os
|
||||
|
||||
# @kludge: it breaks the functional paradigm to a degree, but declaring this
|
||||
# var here (versus within get()) gives us a "poor man's" memoization on the
|
||||
# call to get(). This, in turn, spares us from having to call out to the
|
||||
# filesystem more than once.
|
||||
cheats = {}
|
||||
|
||||
|
||||
def default_path():
|
||||
""" Returns the default cheatsheet path """
|
||||
@ -35,10 +41,15 @@ def default_path():
|
||||
return default_sheets_dir
|
||||
|
||||
|
||||
# @todo: memoize result
|
||||
def get():
|
||||
""" Assembles a dictionary of cheatsheets as name => file-path """
|
||||
cheats = {}
|
||||
|
||||
# if we've already reached out to the filesystem, just return the result
|
||||
# from memory
|
||||
if cheats:
|
||||
return cheats
|
||||
|
||||
# otherwise, scan the filesystem
|
||||
for cheat_dir in reversed(paths()):
|
||||
cheats.update(
|
||||
dict([
|
||||
|
Reference in New Issue
Block a user