# HG changeset patch # User catherine@dellzilla # Date 1224884876 14400 # Node ID c1e5df33721f76f1679d957edc5020c5c214d267 # Parent 234fb764becd315a6f2abf3c5cb0d5d35cc65989 struggling to get data files into setup.py diff -r 234fb764becd -r c1e5df33721f cmd2/example.py --- a/cmd2/example.py Fri Oct 24 16:55:49 2008 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -'''A sample application for cmd2.''' - -from cmd2 import Cmd, make_option, options, Cmd2TestCase -import unittest, optparse, sys - -class CmdLineApp(Cmd): - multilineCommands = ['orate'] - Cmd.shortcuts.update({'&': 'speak'}) - maxrepeats = 3 - Cmd.settable.append('maxrepeats') - - @options([make_option('-p', '--piglatin', action="store_true", help="atinLay"), - make_option('-s', '--shout', action="store_true", help="N00B EMULATION MODE"), - make_option('-r', '--repeat', type="int", help="output [n] times") - ]) - def do_speak(self, arg, opts=None): - """Repeats what you tell me to.""" - arg = ''.join(arg) - if opts.piglatin: - arg = '%s%say' % (arg[1:], arg[0]) - if opts.shout: - arg = arg.upper() - repetitions = opts.repeat or 1 - for i in range(min(repetitions, self.maxrepeats)): - self.stdout.write(arg) - self.stdout.write('\n') - # self.stdout.write is better than "print", because Cmd can be - # initialized with a non-standard output destination - - do_say = do_speak # now "say" is a synonym for "speak" - do_orate = do_speak # another synonym, but this one takes multi-line input - -class TestMyAppCase(Cmd2TestCase): - CmdApp = CmdLineApp - transcriptFileName = 'exampleSession.txt' - -parser = optparse.OptionParser() -parser.add_option('-t', '--test', dest='unittests', action='store_true', default=False, help='Run unit test suite') -(callopts, callargs) = parser.parse_args() -if callopts.unittests: - sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main() - unittest.main() -else: - app = CmdLineApp() - app.cmdloop() diff -r 234fb764becd -r c1e5df33721f cmd2/example/example.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cmd2/example/example.py Fri Oct 24 17:47:56 2008 -0400 @@ -0,0 +1,45 @@ +'''A sample application for cmd2.''' + +from cmd2 import Cmd, make_option, options, Cmd2TestCase +import unittest, optparse, sys + +class CmdLineApp(Cmd): + multilineCommands = ['orate'] + Cmd.shortcuts.update({'&': 'speak'}) + maxrepeats = 3 + Cmd.settable.append('maxrepeats') + + @options([make_option('-p', '--piglatin', action="store_true", help="atinLay"), + make_option('-s', '--shout', action="store_true", help="N00B EMULATION MODE"), + make_option('-r', '--repeat', type="int", help="output [n] times") + ]) + def do_speak(self, arg, opts=None): + """Repeats what you tell me to.""" + arg = ''.join(arg) + if opts.piglatin: + arg = '%s%say' % (arg[1:], arg[0]) + if opts.shout: + arg = arg.upper() + repetitions = opts.repeat or 1 + for i in range(min(repetitions, self.maxrepeats)): + self.stdout.write(arg) + self.stdout.write('\n') + # self.stdout.write is better than "print", because Cmd can be + # initialized with a non-standard output destination + + do_say = do_speak # now "say" is a synonym for "speak" + do_orate = do_speak # another synonym, but this one takes multi-line input + +class TestMyAppCase(Cmd2TestCase): + CmdApp = CmdLineApp + transcriptFileName = 'exampleSession.txt' + +parser = optparse.OptionParser() +parser.add_option('-t', '--test', dest='unittests', action='store_true', default=False, help='Run unit test suite') +(callopts, callargs) = parser.parse_args() +if callopts.unittests: + sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main() + unittest.main() +else: + app = CmdLineApp() + app.cmdloop() diff -r 234fb764becd -r c1e5df33721f cmd2/example/exampleSession.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cmd2/example/exampleSession.txt Fri Oct 24 17:47:56 2008 -0400 @@ -0,0 +1,41 @@ +This is cut-and-pasted from an interactive example.py session. +Calling `example.py -t` runs it as a series of unit tests, +verifying that the same output is still returned. + +(Cmd) say goodnight, Gracie +goodnight, Gracie +(Cmd) say -p goodnight, Gracie +oodnight, Graciegay +(Cmd) say -h +Usage: speak [options] arg + +Options: + -h, --help show this help message and exit + -p, --piglatin atinLay + -s, --shout N00B EMULATION MODE + -r REPEAT, --repeat=REPEAT + output [n] times +(Cmd) say --shout goodnight, Gracie +GOODNIGHT, GRACIE +(Cmd) set prompt 'example >>> ' +prompt - was: (Cmd) +now: example >>> +example >>> say --repeat 5 spam +spam +spam +spam +example >>> set +prompt: example >>> +editor: gedit +echo: False +maxrepeats: 3 +example >>> set maxrepeats 10 +maxrepeats - was: 3 +now: 10 +example >>> say --repeat 5 spam +spam +spam +spam +spam +spam +example >>> \ No newline at end of file diff -r 234fb764becd -r c1e5df33721f cmd2/exampleSession.txt --- a/cmd2/exampleSession.txt Fri Oct 24 16:55:49 2008 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -This is cut-and-pasted from an interactive example.py session. -Calling `example.py -t` runs it as a series of unit tests, -verifying that the same output is still returned. - -(Cmd) say goodnight, Gracie -goodnight, Gracie -(Cmd) say -p goodnight, Gracie -oodnight, Graciegay -(Cmd) say -h -Usage: speak [options] arg - -Options: - -h, --help show this help message and exit - -p, --piglatin atinLay - -s, --shout N00B EMULATION MODE - -r REPEAT, --repeat=REPEAT - output [n] times -(Cmd) say --shout goodnight, Gracie -GOODNIGHT, GRACIE -(Cmd) set prompt 'example >>> ' -prompt - was: (Cmd) -now: example >>> -example >>> say --repeat 5 spam -spam -spam -spam -example >>> set -prompt: example >>> -editor: gedit -echo: False -maxrepeats: 3 -example >>> set maxrepeats 10 -maxrepeats - was: 3 -now: 10 -example >>> say --repeat 5 spam -spam -spam -spam -spam -spam -example >>> \ No newline at end of file diff -r 234fb764becd -r c1e5df33721f setup.py --- a/setup.py Fri Oct 24 16:55:49 2008 -0400 +++ b/setup.py Fri Oct 24 17:47:56 2008 -0400 @@ -4,8 +4,10 @@ setup( name="cmd2", packages=["cmd2",], + package_dir={'cmd2': 'cmd2'}, + package_data={'cmd2': ['example/*.*']}, + include_package_data=True, version="0.4", - #py_modules = ['cmd2','flagReader','bootstrap'], # metadata for upload to PyPI author = 'Catherine Devlin', @@ -14,7 +16,6 @@ license = 'MIT', keywords = 'command prompt console cmd', url = 'http://www.assembla.com/wiki/show/python-cmd2', - include_package_data=True, long_description = """Enhancements for standard library's cmd module.