Package with distutils

Created cheatsheets package to store the default sheets.
This commit is contained in:
Louis Taylor 2013-08-13 11:01:06 +01:00
parent 098384d341
commit 8dda6a9241
23 changed files with 26 additions and 6 deletions

13
cheat
View file

@ -1,18 +1,18 @@
#!/usr/bin/env python #!/usr/bin/env python
import os import os
import sys import sys
from cheatsheets import cheat_dir
# assemble a keyphrase out of all params passed to the script # assemble a keyphrase out of all params passed to the script
keyphrase = ' '.join(sys.argv[1:]) keyphrase = ' '.join(sys.argv[1:])
cheat_dir = os.path.expanduser('~') + '/.cheat/'
# verify that the ~/.cheat directory exists # verify that the cheat directory exists
if not os.path.isdir(cheat_dir): if not os.path.isdir(cheat_dir):
print >> sys.stderr, 'The ~/.cheat directory does not exist.' print >> sys.stderr, 'The cheat directory does not exist.'
exit() exit()
# list the files in the ~/.cheat directory # list the files in the cheat directory
cheatsheets = os.listdir(cheat_dir) cheatsheets = [f for f in os.listdir(cheat_dir) if '.' not in f]
cheatsheets.sort() cheatsheets.sort()
# print help if requested # print help if requested
@ -24,7 +24,8 @@ if keyphrase in ['', 'help', '--help', '-h']:
# print the cheatsheet if it exists # print the cheatsheet if it exists
if keyphrase in cheatsheets: if keyphrase in cheatsheets:
with open (cheat_dir + keyphrase, 'r') as cheatsheet: cheatsheet_filename = os.path.join(cheat_dir, keyphrase)
with open(cheatsheet_filename, 'r') as cheatsheet:
print cheatsheet.read() print cheatsheet.read()
# if it does not, say so # if it does not, say so

3
cheatsheets/__init__.py Normal file
View file

@ -0,0 +1,3 @@
import os
cheat_dir, __init = os.path.split(__file__)

16
setup.py Normal file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env python
from distutils.core import setup
import os
setup(name='cheat',
version='1.0',
description='Create and view interactive cheatsheets on the command-line',
author='Chris Lane',
author_email='chris@chris-allen-lane.com',
url='https://github.com/chrisallenlane/cheat',
packages=['cheatsheets'],
package_data={'cheatsheets': [f for f in os.listdir('cheatsheets')
if '.' not in f]},
scripts=['cheat']
)