From 04cdcb0feb369ac4c60e10ccdc139c57e8b52e62 Mon Sep 17 00:00:00 2001 From: Zearin Date: Fri, 7 Oct 2011 10:34:23 -0400 Subject: Removed leftovers from installing with pip. Oops! I noticed there was a bunch of extra crap left over from when I installed this module onto my own system. I thought it wouldn't have modified itself at the time (just the Python module library on my system), but I was wrong. Begone, useless cruft! --- doxygen/html/classcmd2_1_1Cmd.html | 3767 ------------------------------------ 1 file changed, 3767 deletions(-) delete mode 100644 doxygen/html/classcmd2_1_1Cmd.html (limited to 'doxygen/html/classcmd2_1_1Cmd.html') diff --git a/doxygen/html/classcmd2_1_1Cmd.html b/doxygen/html/classcmd2_1_1Cmd.html deleted file mode 100644 index ec17cf5..0000000 --- a/doxygen/html/classcmd2_1_1Cmd.html +++ /dev/null @@ -1,3767 +0,0 @@ - - - - -Cmd2: cmd2::Cmd Class Reference - - - - - - - - - - - - - - -
- - -
- - - - - - - - - - - -
-
Cmd2 - -
- -
-
- - - - - -
-
- -
-
-
- -
- -
-
-Inheritance diagram for cmd2::Cmd:
-
-
- - -example::CmdLineApp -pirate6::Pirate -pirate7::Pirate -pirate8::Pirate - -
- -

List of all members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

-Public Member Functions

def __init__
def cmdloop
def colorize
def complete_statement
def do__relative_load
def do_cmdenvironment
def do_ed
def do_EOF
def do_help
def do_history
def do_list
def do_load
def do_pause
def do_py
def do_quit
def do_run
def do_save
def do_set
def do_shell
def do_shortcuts
def do_show
def fileimport
def func_named
def last_matching
def onecmd
def onecmd_plus_hooks
def parsed
def perror
def pfeedback
def postparse
def postparsing_postcmd
def postparsing_precmd
def poutput
def preparse
def pseudo_raw_input
def read_file_or_url
def redirect_output
def restore_output
def run_commands_at_invocation
def runTranscriptTests
def select

-Public Attributes

 blankLineTerminationParser
 blankLineTerminator
 continuation_prompt
 history
 initial_stdout
 inputParser
 intro
 kept_sys
 keywords
 lastcmd
 multilineCommand
 multilineParser
 old_completer
 parser
 prompt
 pystate
 redirect
 shortcuts
 singleLineParser
 stdin
 stdout
 use_rawinput

-Static Public Attributes

 abbrev = True
 blankLinesAllowed = False
 case_insensitive = True
dictionary colorcodes
tuple colors = (platform.system() != 'Windows')
tuple commentGrammars = pyparsing.Or([pyparsing.pythonStyleComment, pyparsing.cStyleComment])
tuple commentInProgress = pyparsing.Literal('/*')
string continuation_prompt = '> '
 current_script_dir = None
 debug = False
string default_file_name = 'command.txt'
 default_to_shell = False
string defaultExtension = 'txt'
 do__load = do_load
 do_edit = do_ed
 do_eof = do_EOF
 do_exit = do_quit
 do_hi = do_history
 do_l = do_list
 do_li = do_list
 do_q = do_quit
 do_r = do_run
 echo = False
tuple editor = os.environ.get('EDITOR')
string editor = 'notepad'
string excludeFromHistory = '''run r list l history hi ed edit li eof'''
 feedback_to_output = False
string help = "describe function of parameter"
 kept_state = None
string legalChars = u'!#$%.:?@_'
 locals_in_py = True
list multilineCommands = []
string noSpecialParse = 'set ed edit exit'
tuple prefixParser = pyparsing.Empty()
 quiet = False
string redirector = '>'
list reserved_words = []
tuple saveparser
tuple settable
dictionary shortcuts = {'?': 'help', '!': 'shell', '@': 'load', '@@': '_relative_load'}
list terminators = [';']
 timing = False
tuple urlre = re.compile('(https?://[-\\w\\./]+)')

-Private Member Functions

def _cmdloop
def _default
def _init_parser

-Static Private Attributes

 _STOP_AND_EXIT = True
int _STOP_SCRIPT_NO_EXIT = 999
-

Detailed Description

-
-

Definition at line 361 of file cmd2.py.

-

Constructor & Destructor Documentation

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::__init__ ( self,
 args,
 kwargs 
)
-
-
- -

Definition at line 469 of file cmd2.py.

-
00469 
-00470     def __init__(self, *args, **kwargs):        
-00471         cmd.Cmd.__init__(self, *args, **kwargs)
-00472         self.initial_stdout = sys.stdout
-00473         self.history = History()
-00474         self.pystate = {}
-00475         self.shortcuts = sorted(self.shortcuts.items(), reverse=True)
-00476         self.keywords = self.reserved_words + [fname[3:] for fname in dir(self) 
-00477                                                if fname.startswith('do_')]            
-00478         self._init_parser()
-            
-
-
-
-

Member Function Documentation

- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::_cmdloop ( self,
 intro = None 
) [private]
-
-
-
Repeatedly issue a prompt, accept input, parse an initial prefix
-off the received input, and dispatch to action methods, passing them
-the remainder of the line as argument.
-
-

Definition at line 895 of file cmd2.py.

- -

Referenced by cmdloop().

-
00895 
-00896     def _cmdloop(self, intro=None):
-00897         """Repeatedly issue a prompt, accept input, parse an initial prefix
-00898         off the received input, and dispatch to action methods, passing them
-00899         the remainder of the line as argument.
-00900         """
-00901 
-00902         # An almost perfect copy from Cmd; however, the pseudo_raw_input portion
-00903         # has been split out so that it can be called separately
-00904         
-00905         self.preloop()
-00906         if self.use_rawinput and self.completekey:
-00907             try:
-00908                 import readline
-00909                 self.old_completer = readline.get_completer()
-00910                 readline.set_completer(self.complete)
-00911                 readline.parse_and_bind(self.completekey+": complete")
-00912             except ImportError:
-00913                 pass
-00914         try:
-00915             if intro is not None:
-00916                 self.intro = intro
-00917             if self.intro:
-00918                 self.stdout.write(str(self.intro)+"\n")
-00919             stop = None
-00920             while not stop:
-00921                 if self.cmdqueue:
-00922                     line = self.cmdqueue.pop(0)
-00923                 else:
-00924                     line = self.pseudo_raw_input(self.prompt)
-00925                 if (self.echo) and (isinstance(self.stdin, file)):
-00926                     self.stdout.write(line + '\n')
-00927                 stop = self.onecmd_plus_hooks(line)
-00928             self.postloop()
-00929         finally:
-00930             if self.use_rawinput and self.completekey:
-00931                 try:
-00932                     import readline
-00933                     readline.set_completer(self.old_completer)
-00934                 except ImportError:
-00935                     pass    
-00936             return stop
-
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::_default ( self,
 statement 
) [private]
-
-
- -

Definition at line 868 of file cmd2.py.

- -

References pirate6::Pirate::default(), pirate8::Pirate::default(), pirate7::Pirate::default(), default_to_shell, and postparsing_postcmd().

-
00868 
-00869     def _default(self, statement):
-00870         arg = statement.full_parsed_statement()
-00871         if self.default_to_shell:
-00872             result = os.system(arg)
-00873             if not result:
-00874                 return self.postparsing_postcmd(None)
-00875         return self.postparsing_postcmd(self.default(arg))
-
-
-
-
- -
-
- - - - - - - - -
def cmd2::Cmd::_init_parser ( self) [private]
-
-
- -

Definition at line 493 of file cmd2.py.

-
00493 
-00494     def _init_parser(self):
-00495         r'''
-00496         >>> c = Cmd()
-00497         >>> c.multilineCommands = ['multiline']
-00498         >>> c.case_insensitive = True
-00499         >>> c._init_parser()
-00500         >>> print (c.parser.parseString('').dump())
-00501         []
-00502         >>> print (c.parser.parseString('').dump())
-00503         []        
-00504         >>> print (c.parser.parseString('/* empty command */').dump())
-00505         []        
-00506         >>> print (c.parser.parseString('plainword').dump())
-00507         ['plainword', '']
-00508         - command: plainword
-00509         - statement: ['plainword', '']
-00510           - command: plainword        
-00511         >>> print (c.parser.parseString('termbare;').dump())
-00512         ['termbare', '', ';', '']
-00513         - command: termbare
-00514         - statement: ['termbare', '', ';']
-00515           - command: termbare
-00516           - terminator: ;
-00517         - terminator: ;        
-00518         >>> print (c.parser.parseString('termbare; suffx').dump())
-00519         ['termbare', '', ';', 'suffx']
-00520         - command: termbare
-00521         - statement: ['termbare', '', ';']
-00522           - command: termbare
-00523           - terminator: ;
-00524         - suffix: suffx
-00525         - terminator: ;        
-00526         >>> print (c.parser.parseString('barecommand').dump())
-00527         ['barecommand', '']
-00528         - command: barecommand
-00529         - statement: ['barecommand', '']
-00530           - command: barecommand
-00531         >>> print (c.parser.parseString('COMmand with args').dump())
-00532         ['command', 'with args']
-00533         - args: with args
-00534         - command: command
-00535         - statement: ['command', 'with args']
-00536           - args: with args
-00537           - command: command
-00538         >>> print (c.parser.parseString('command with args and terminator; and suffix').dump())
-00539         ['command', 'with args and terminator', ';', 'and suffix']
-00540         - args: with args and terminator
-00541         - command: command
-00542         - statement: ['command', 'with args and terminator', ';']
-00543           - args: with args and terminator
-00544           - command: command
-00545           - terminator: ;
-00546         - suffix: and suffix
-00547         - terminator: ;
-00548         >>> print (c.parser.parseString('simple | piped').dump())
-00549         ['simple', '', '|', ' piped']
-00550         - command: simple
-00551         - pipeTo:  piped
-00552         - statement: ['simple', '']
-00553           - command: simple
-00554         >>> print (c.parser.parseString('double-pipe || is not a pipe').dump())
-00555         ['double', '-pipe || is not a pipe']
-00556         - args: -pipe || is not a pipe
-00557         - command: double
-00558         - statement: ['double', '-pipe || is not a pipe']
-00559           - args: -pipe || is not a pipe
-00560           - command: double
-00561         >>> print (c.parser.parseString('command with args, terminator;sufx | piped').dump())
-00562         ['command', 'with args, terminator', ';', 'sufx', '|', ' piped']
-00563         - args: with args, terminator
-00564         - command: command
-00565         - pipeTo:  piped
-00566         - statement: ['command', 'with args, terminator', ';']
-00567           - args: with args, terminator
-00568           - command: command
-00569           - terminator: ;
-00570         - suffix: sufx
-00571         - terminator: ;
-00572         >>> print (c.parser.parseString('output into > afile.txt').dump())
-00573         ['output', 'into', '>', 'afile.txt']
-00574         - args: into
-00575         - command: output
-00576         - output: >
-00577         - outputTo: afile.txt
-00578         - statement: ['output', 'into']
-00579           - args: into
-00580           - command: output   
-00581         >>> print (c.parser.parseString('output into;sufx | pipethrume plz > afile.txt').dump())
-00582         ['output', 'into', ';', 'sufx', '|', ' pipethrume plz', '>', 'afile.txt']
-00583         - args: into
-00584         - command: output
-00585         - output: >
-00586         - outputTo: afile.txt
-00587         - pipeTo:  pipethrume plz
-00588         - statement: ['output', 'into', ';']
-00589           - args: into
-00590           - command: output
-00591           - terminator: ;
-00592         - suffix: sufx
-00593         - terminator: ;
-00594         >>> print (c.parser.parseString('output to paste buffer >> ').dump())
-00595         ['output', 'to paste buffer', '>>', '']
-00596         - args: to paste buffer
-00597         - command: output
-00598         - output: >>
-00599         - statement: ['output', 'to paste buffer']
-00600           - args: to paste buffer
-00601           - command: output
-00602         >>> print (c.parser.parseString('ignore the /* commented | > */ stuff;').dump())
-00603         ['ignore', 'the /* commented | > */ stuff', ';', '']
-00604         - args: the /* commented | > */ stuff
-00605         - command: ignore
-00606         - statement: ['ignore', 'the /* commented | > */ stuff', ';']
-00607           - args: the /* commented | > */ stuff
-00608           - command: ignore
-00609           - terminator: ;
-00610         - terminator: ;
-00611         >>> print (c.parser.parseString('has > inside;').dump())
-00612         ['has', '> inside', ';', '']
-00613         - args: > inside
-00614         - command: has
-00615         - statement: ['has', '> inside', ';']
-00616           - args: > inside
-00617           - command: has
-00618           - terminator: ;
-00619         - terminator: ;        
-00620         >>> print (c.parser.parseString('multiline has > inside an unfinished command').dump())
-00621         ['multiline', ' has > inside an unfinished command']
-00622         - multilineCommand: multiline        
-00623         >>> print (c.parser.parseString('multiline has > inside;').dump())
-00624         ['multiline', 'has > inside', ';', '']
-00625         - args: has > inside
-00626         - multilineCommand: multiline
-00627         - statement: ['multiline', 'has > inside', ';']
-00628           - args: has > inside
-00629           - multilineCommand: multiline
-00630           - terminator: ;
-00631         - terminator: ;        
-00632         >>> print (c.parser.parseString('multiline command /* with comment in progress;').dump())
-00633         ['multiline', ' command /* with comment in progress;']
-00634         - multilineCommand: multiline
-00635         >>> print (c.parser.parseString('multiline command /* with comment complete */ is done;').dump())
-00636         ['multiline', 'command /* with comment complete */ is done', ';', '']
-00637         - args: command /* with comment complete */ is done
-00638         - multilineCommand: multiline
-00639         - statement: ['multiline', 'command /* with comment complete */ is done', ';']
-00640           - args: command /* with comment complete */ is done
-00641           - multilineCommand: multiline
-00642           - terminator: ;
-00643         - terminator: ;
-00644         >>> print (c.parser.parseString('multiline command ends\n\n').dump())
-00645         ['multiline', 'command ends', '\n', '\n']
-00646         - args: command ends
-00647         - multilineCommand: multiline
-00648         - statement: ['multiline', 'command ends', '\n', '\n']
-00649           - args: command ends
-00650           - multilineCommand: multiline
-00651           - terminator: ['\n', '\n']
-00652         - terminator: ['\n', '\n']
-00653         >>> print (c.parser.parseString('multiline command "with term; ends" now\n\n').dump())
-00654         ['multiline', 'command "with term; ends" now', '\n', '\n']
-00655         - args: command "with term; ends" now
-00656         - multilineCommand: multiline
-00657         - statement: ['multiline', 'command "with term; ends" now', '\n', '\n']
-00658           - args: command "with term; ends" now
-00659           - multilineCommand: multiline
-00660           - terminator: ['\n', '\n']
-00661         - terminator: ['\n', '\n']
-00662         >>> print (c.parser.parseString('what if "quoted strings /* seem to " start comments?').dump())
-00663         ['what', 'if "quoted strings /* seem to " start comments?']
-00664         - args: if "quoted strings /* seem to " start comments?
-00665         - command: what
-00666         - statement: ['what', 'if "quoted strings /* seem to " start comments?']
-00667           - args: if "quoted strings /* seem to " start comments?
-00668           - command: what
-00669         '''
-00670         #outputParser = (pyparsing.Literal('>>') | (pyparsing.WordStart() + '>') | pyparsing.Regex('[^=]>'))('output')
-00671         outputParser = (pyparsing.Literal(self.redirector *2) | \
-00672                        (pyparsing.WordStart() + self.redirector) | \
-00673                         pyparsing.Regex('[^=]' + self.redirector))('output')
-00674         
-00675         terminatorParser = pyparsing.Or([(hasattr(t, 'parseString') and t) or pyparsing.Literal(t) for t in self.terminators])('terminator')
-00676         stringEnd = pyparsing.stringEnd ^ '\nEOF'
-00677         self.multilineCommand = pyparsing.Or([pyparsing.Keyword(c, caseless=self.case_insensitive) for c in self.multilineCommands])('multilineCommand')
-00678         oneLineCommand = (~self.multilineCommand + pyparsing.Word(self.legalChars))('command')
-00679         pipe = pyparsing.Keyword('|', identChars='|')
-00680         self.commentGrammars.ignore(pyparsing.quotedString).setParseAction(lambda x: '')
-00681         doNotParse = self.commentGrammars | self.commentInProgress | pyparsing.quotedString
-00682         afterElements = \
-00683             pyparsing.Optional(pipe + pyparsing.SkipTo(outputParser ^ stringEnd, ignore=doNotParse)('pipeTo')) + \
-00684             pyparsing.Optional(outputParser + pyparsing.SkipTo(stringEnd, ignore=doNotParse).setParseAction(lambda x: x[0].strip())('outputTo'))
-00685         if self.case_insensitive:
-00686             self.multilineCommand.setParseAction(lambda x: x[0].lower())
-00687             oneLineCommand.setParseAction(lambda x: x[0].lower())
-00688         if self.blankLinesAllowed:
-00689             self.blankLineTerminationParser = pyparsing.NoMatch
-00690         else:
-00691             self.blankLineTerminator = (pyparsing.lineEnd + pyparsing.lineEnd)('terminator')
-00692             self.blankLineTerminator.setResultsName('terminator')
-00693             self.blankLineTerminationParser = ((self.multilineCommand ^ oneLineCommand) + pyparsing.SkipTo(self.blankLineTerminator, ignore=doNotParse).setParseAction(lambda x: x[0].strip())('args') + self.blankLineTerminator)('statement')
-00694         self.multilineParser = (((self.multilineCommand ^ oneLineCommand) + pyparsing.SkipTo(terminatorParser, ignore=doNotParse).setParseAction(lambda x: x[0].strip())('args') + terminatorParser)('statement') +
-00695                                 pyparsing.SkipTo(outputParser ^ pipe ^ stringEnd, ignore=doNotParse).setParseAction(lambda x: x[0].strip())('suffix') + afterElements)
-00696         self.multilineParser.ignore(self.commentInProgress)
-00697         self.singleLineParser = ((oneLineCommand + pyparsing.SkipTo(terminatorParser ^ stringEnd ^ pipe ^ outputParser, ignore=doNotParse).setParseAction(lambda x:x[0].strip())('args'))('statement') +
-00698                                  pyparsing.Optional(terminatorParser) + afterElements)
-00699         #self.multilineParser = self.multilineParser.setResultsName('multilineParser')
-00700         #self.singleLineParser = self.singleLineParser.setResultsName('singleLineParser')
-00701         self.blankLineTerminationParser = self.blankLineTerminationParser.setResultsName('statement')
-00702         self.parser = self.prefixParser + (
-00703             stringEnd |
-00704             self.multilineParser |
-00705             self.singleLineParser |
-00706             self.blankLineTerminationParser | 
-00707             self.multilineCommand + pyparsing.SkipTo(stringEnd, ignore=doNotParse)
-00708             )
-00709         self.parser.ignore(self.commentGrammars)
-00710         
-00711         inputMark = pyparsing.Literal('<')
-00712         inputMark.setParseAction(lambda x: '')
-00713         fileName = pyparsing.Word(self.legalChars + '/\\')
-00714         inputFrom = fileName('inputFrom')
-00715         inputFrom.setParseAction(replace_with_file_contents)
-00716         # a not-entirely-satisfactory way of distinguishing < as in "import from" from <
-00717         # as in "lesser than"
-00718         self.inputParser = inputMark + pyparsing.Optional(inputFrom) + pyparsing.Optional('>') + \
-00719                            pyparsing.Optional(fileName) + (pyparsing.stringEnd | '|')
-00720         self.inputParser.ignore(self.commentInProgress)               
-    
-
-
-
- -
-
- - - - - - - - -
def cmd2::Cmd::cmdloop ( self)
-
-
- -

Definition at line 1283 of file cmd2.py.

- -

References _cmdloop(), run_commands_at_invocation(), and runTranscriptTests().

-
01283 
-01284     def cmdloop(self):
-01285         parser = optparse.OptionParser()
-01286         parser.add_option('-t', '--test', dest='test',
-01287                action="store_true", 
-01288                help='Test against transcript(s) in FILE (wildcards OK)')
-01289         (callopts, callargs) = parser.parse_args()
-01290         if callopts.test:
-01291             self.runTranscriptTests(callargs)
-01292         else:
-01293             if not self.run_commands_at_invocation(callargs):
-01294                 self._cmdloop()   
-            
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::colorize ( self,
 val,
 color 
)
-
-
-
Given a string (``val``), returns that string wrapped in UNIX-style 
-   special characters that turn on (and then off) text color and style.
-   If the ``colors`` environment paramter is ``False``, or the application
-   is running on Windows, will return ``val`` unchanged.
-   ``color`` should be one of the supported strings (or styles):
-   red/blue/green/cyan/magenta, bold, underline
-

Definition at line 435 of file cmd2.py.

- -

Referenced by pirate7::Pirate::do_sing(), and pirate8::Pirate::do_sing().

-
00435 
-00436     def colorize(self, val, color):
-00437         '''Given a string (``val``), returns that string wrapped in UNIX-style 
-00438            special characters that turn on (and then off) text color and style.
-00439            If the ``colors`` environment paramter is ``False``, or the application
-00440            is running on Windows, will return ``val`` unchanged.
-00441            ``color`` should be one of the supported strings (or styles):
-00442            red/blue/green/cyan/magenta, bold, underline'''
-00443         if self.colors and (self.stdout == self.initial_stdout):
-00444             return self.colorcodes[color][True] + val + self.colorcodes[color][False]
-00445         return val
-
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::complete_statement ( self,
 line 
)
-
-
-
Keep accepting lines of input until the command is complete.
-

Definition at line 794 of file cmd2.py.

- -

References commentGrammars, continuation_prompt, parsed(), and pseudo_raw_input().

- -

Referenced by onecmd_plus_hooks().

-
00794 
-00795     def complete_statement(self, line):
-00796         """Keep accepting lines of input until the command is complete."""
-00797         if (not line) or (
-00798             not pyparsing.Or(self.commentGrammars).
-00799                 setParseAction(lambda x: '').transformString(line)):
-00800             raise EmptyStatement
-00801         statement = self.parsed(line)
-00802         while statement.parsed.multilineCommand and (statement.parsed.terminator == ''):
-00803             statement = '%s\n%s' % (statement.parsed.raw, 
-00804                                     self.pseudo_raw_input(self.continuation_prompt))                
-00805             statement = self.parsed(statement)
-00806         if not statement.parsed.command:
-00807             raise EmptyStatement
-00808         return statement
-    
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::do__relative_load ( self,
 arg = None 
)
-
-
-
-Runs commands in script at file or URL; if this is called from within an
-already-running script, the filename will be interpreted relative to the 
-already-running script's directory.
-

Definition at line 1206 of file cmd2.py.

- -

References current_script_dir, and do__load.

-
01206 
-01207     def do__relative_load(self, arg=None):
-01208         '''
-01209         Runs commands in script at file or URL; if this is called from within an
-01210         already-running script, the filename will be interpreted relative to the 
-01211         already-running script's directory.'''
-01212         if arg:
-01213             arg = arg.split(None, 1)
-01214             targetname, args = arg[0], (arg[1:] or [''])[0]
-01215             targetname = os.path.join(self.current_script_dir or '', targetname)
-01216             self.do__load('%s %s' % (targetname, args))
-    
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::do_cmdenvironment ( self,
 args 
)
-
-
-
Summary report of interactive parameters.
-

Definition at line 446 of file cmd2.py.

- -

References case_insensitive, settable, and terminators.

-
00446 
-00447     def do_cmdenvironment(self, args):
-00448         '''Summary report of interactive parameters.'''
-00449         self.stdout.write("""
-00450         Commands are %(casesensitive)scase-sensitive.
-00451         Commands may be terminated with: %(terminators)s
-00452         Settable parameters: %(settable)s\n""" % \
-00453         { 'casesensitive': (self.case_insensitive and 'not ') or '',
-00454           'terminators': str(self.terminators),
-00455           'settable': ' '.join(self.settable)
-00456         })
-        
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::do_ed ( self,
 arg 
)
-
-
-
ed: edit most recent command in text editor
-ed [N]: edit numbered command from history
-ed [filename]: edit specified file name
-
-commands are run after editor is closed.
-"set edit (program-name)" or set  EDITOR environment variable
-to control which editing program is used.
-

Definition at line 1128 of file cmd2.py.

- -

References default_file_name, do__load, editor, history, and last_matching().

-
01128 
-01129     def do_ed(self, arg):
-01130         """ed: edit most recent command in text editor
-01131         ed [N]: edit numbered command from history
-01132         ed [filename]: edit specified file name
-01133         
-01134         commands are run after editor is closed.
-01135         "set edit (program-name)" or set  EDITOR environment variable
-01136         to control which editing program is used."""
-01137         if not self.editor:
-01138             raise EnvironmentError("Please use 'set editor' to specify your text editing program of choice.")
-01139         filename = self.default_file_name
-01140         if arg:
-01141             try:
-01142                 buffer = self.last_matching(int(arg))
-01143             except ValueError:
-01144                 filename = arg
-01145                 buffer = ''
-01146         else:
-01147             buffer = self.history[-1]
-01148 
-01149         if buffer:
-01150             f = open(os.path.expanduser(filename), 'w')
-01151             f.write(buffer or '')
-01152             f.close()        
-01153                 
-01154         os.system('%s %s' % (self.editor, filename))
-        self.do__load(filename)
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::do_EOF ( self,
 arg 
)
-
-
- -

Definition at line 937 of file cmd2.py.

- -

References _STOP_SCRIPT_NO_EXIT.

-
00937 
-00938     def do_EOF(self, arg):
-        return self._STOP_SCRIPT_NO_EXIT # End of script; should not exit app
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::do_help ( self,
 arg 
)
-
-
- -

Definition at line 457 of file cmd2.py.

- -

References func_named(), and stdout.

-
00457 
-00458     def do_help(self, arg):
-00459         if arg:
-00460             funcname = self.func_named(arg)
-00461             if funcname:
-00462                 fn = getattr(self, funcname)
-00463                 try:
-00464                     fn.optionParser.print_help(file=self.stdout)
-00465                 except AttributeError:
-00466                     cmd.Cmd.do_help(self, funcname[3:])
-00467         else:
-00468             cmd.Cmd.do_help(self, arg)
-        
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::do_history ( self,
 arg,
 opts 
)
-
-
-
history [arg]: lists past commands issued
-
-| no arg:         list all
-| arg is integer: list one history item, by index
-| arg is string:  string search
-| arg is /enclosed in forward-slashes/: regular expression search
-
-

Definition at line 1083 of file cmd2.py.

- -

References history, and poutput().

-
01083 
-01084     def do_history(self, arg, opts):
-01085         """history [arg]: lists past commands issued
-01086         
-01087         | no arg:         list all
-01088         | arg is integer: list one history item, by index
-01089         | arg is string:  string search
-01090         | arg is /enclosed in forward-slashes/: regular expression search
-01091         """
-01092         if arg:
-01093             history = self.history.get(arg)
-01094         else:
-01095             history = self.history
-01096         for hi in history:
-01097             if opts.script:
-01098                 self.poutput(hi)
-01099             else:
-                self.stdout.write(hi.pr())
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::do_list ( self,
 arg 
)
-
-
-
list [arg]: lists last command issued
-
-no arg -> list most recent command
-arg is integer -> list one history item, by index
-a..b, a:b, a:, ..b -> list spans from a (or start) to b (or end)
-arg is string -> list all commands matching string search
-arg is /enclosed in forward-slashes/ -> regular expression search
-
-

Definition at line 1108 of file cmd2.py.

- -

References poutput().

-
01108 
-01109     def do_list(self, arg):
-01110         """list [arg]: lists last command issued
-01111         
-01112         no arg -> list most recent command
-01113         arg is integer -> list one history item, by index
-01114         a..b, a:b, a:, ..b -> list spans from a (or start) to b (or end)
-01115         arg is string -> list all commands matching string search
-01116         arg is /enclosed in forward-slashes/ -> regular expression search
-01117         """
-01118         try:
-01119             history = self.history.span(arg or '-1')
-01120         except IndexError:
-01121             history = self.history.search(arg)
-01122         for hi in history:
-01123             self.poutput(hi.pr())
-
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::do_load ( self,
 arg = None 
)
-
-
-
Runs script of command(s) from a file or URL.
-

Definition at line 1218 of file cmd2.py.

-
01218 
-01219     def do_load(self, arg=None):           
-01220         """Runs script of command(s) from a file or URL."""
-01221         if arg is None:
-01222             targetname = self.default_file_name
-01223         else:
-01224             arg = arg.split(None, 1)
-01225             targetname, args = arg[0], (arg[1:] or [''])[0].strip()
-01226         try:
-01227             target = self.read_file_or_url(targetname)
-01228         except IOError, e:
-01229             self.perror('Problem accessing script from %s: \n%s' % (targetname, e))
-01230             return
-01231         keepstate = Statekeeper(self, ('stdin','use_rawinput','prompt',
-01232                                        'continuation_prompt','current_script_dir'))
-01233         self.stdin = target    
-01234         self.use_rawinput = False
-01235         self.prompt = self.continuation_prompt = ''
-01236         self.current_script_dir = os.path.split(targetname)[0]
-01237         stop = self._cmdloop()
-01238         self.stdin.close()
-01239         keepstate.restore()
-01240         self.lastcmd = ''
-        return stop and (stop != self._STOP_SCRIPT_NO_EXIT)    
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::do_pause ( self,
 arg 
)
-
-
- -

Definition at line 1031 of file cmd2.py.

-
01031 
-01032     def do_pause(self, arg):
-01033         'Displays the specified text then waits for the user to press RETURN.'
-01034         raw_input(arg + '\n')
-        
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::do_py ( self,
 arg 
)
-
-
-
-py <command>: Executes a Python command.
-py: Enters interactive Python mode.
-End with ``Ctrl-D`` (Unix) / ``Ctrl-Z`` (Windows), ``quit()``, '`exit()``.
-Non-python commands can be issued with ``cmd("your command")``.
-Run python code from external files with ``run("filename.py")``
-
-

Definition at line 1039 of file cmd2.py.

- -

References do_py(), locals_in_py, onecmd_plus_hooks(), cmd2::options(), perror(), pystate, stdin, and stdout.

- -

Referenced by do_py().

-
01039 
-01040     def do_py(self, arg):  
-01041         '''
-01042         py <command>: Executes a Python command.
-01043         py: Enters interactive Python mode.
-01044         End with ``Ctrl-D`` (Unix) / ``Ctrl-Z`` (Windows), ``quit()``, '`exit()``.
-01045         Non-python commands can be issued with ``cmd("your command")``.
-01046         Run python code from external files with ``run("filename.py")``
-01047         '''
-01048         self.pystate['self'] = self
-01049         arg = arg.parsed.raw[2:].strip()
-01050         localvars = (self.locals_in_py and self.pystate) or {}
-01051         interp = InteractiveConsole(locals=localvars)
-01052         interp.runcode('import sys, os;sys.path.insert(0, os.getcwd())')
-01053         if arg.strip():
-01054             interp.runcode(arg)
-01055         else:
-01056             def quit():
-01057                 raise EmbeddedConsoleExit
-01058             def onecmd_plus_hooks(arg):
-01059                 return self.onecmd_plus_hooks(arg + '\n')
-01060             def run(arg):
-01061                 try:
-01062                     file = open(arg)
-01063                     interp.runcode(file.read())
-01064                     file.close()
-01065                 except IOError, e:
-01066                     self.perror(e)
-01067             self.pystate['quit'] = quit
-01068             self.pystate['exit'] = quit
-01069             self.pystate['cmd'] = onecmd_plus_hooks
-01070             self.pystate['run'] = run
-01071             try:
-01072                 cprt = 'Type "help", "copyright", "credits" or "license" for more information.'        
-01073                 keepstate = Statekeeper(sys, ('stdin','stdout'))
-01074                 sys.stdout = self.stdout
-01075                 sys.stdin = self.stdin
-01076                 interp.interact(banner= "Python %s on %s\n%s\n(%s)\n%s" %
-01077                        (sys.version, sys.platform, cprt, self.__class__.__name__, self.do_py.__doc__))
-01078             except EmbeddedConsoleExit:
-01079                 pass
-01080             keepstate.restore()
-            
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::do_quit ( self,
 arg 
)
-
-
- -

Reimplemented in pirate6::Pirate, pirate7::Pirate, and pirate8::Pirate.

- -

Definition at line 941 of file cmd2.py.

- -

References _STOP_AND_EXIT.

-
00941 
-00942     def do_quit(self, arg):
-        return self._STOP_AND_EXIT
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::do_run ( self,
 arg 
)
-
-
-
run [arg]: re-runs an earlier command
-
-no arg -> run most recent command
-arg is integer -> run one history item, by index
-arg is string -> run most recent command by string search
-arg is /enclosed in forward-slashes/ -> run most recent by regex
-
-

Definition at line 1243 of file cmd2.py.

- -

References last_matching(), onecmd_plus_hooks(), and pfeedback().

-
01243 
-01244     def do_run(self, arg):
-01245         """run [arg]: re-runs an earlier command
-01246         
-01247         no arg -> run most recent command
-01248         arg is integer -> run one history item, by index
-01249         arg is string -> run most recent command by string search
-01250         arg is /enclosed in forward-slashes/ -> run most recent by regex
-01251         """        
-01252         'run [N]: runs the SQL that was run N commands ago'
-01253         runme = self.last_matching(arg)
-01254         self.pfeedback(runme)
-01255         if runme:
-            stop = self.onecmd_plus_hooks(runme)
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::do_save ( self,
 arg 
)
-
-
-
`save [N] [filename.ext]`
-
-Saves command from history to file.
-
-| N => Number of command (from history), or `*`; 
-|      most recent command if omitted
-

Definition at line 1160 of file cmd2.py.

- -

References default_file_name, do_save(), history, perror(), and pfeedback().

- -

Referenced by do_save().

-
01160 
-01161     def do_save(self, arg):
-01162         """`save [N] [filename.ext]`
-01163 
-01164         Saves command from history to file.
-01165 
-01166         | N => Number of command (from history), or `*`; 
-01167         |      most recent command if omitted"""
-01168 
-01169         try:
-01170             args = self.saveparser.parseString(arg)
-01171         except pyparsing.ParseException:
-01172             self.perror('Could not understand save target %s' % arg)
-01173             raise SyntaxError(self.do_save.__doc__)
-01174         fname = args.fname or self.default_file_name
-01175         if args.idx == '*':
-01176             saveme = '\n\n'.join(self.history[:])
-01177         elif args.idx:
-01178             saveme = self.history[int(args.idx)-1]
-01179         else:
-01180             saveme = self.history[-1]
-01181         try:
-01182             f = open(os.path.expanduser(fname), 'w')
-01183             f.write(saveme)
-01184             f.close()
-01185             self.pfeedback('Saved to %s' % (fname))
-01186         except Exception, e:
-01187             self.perror('Error saving %s' % (fname))
-01188             raise
-            
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::do_set ( self,
 arg 
)
-
-
-
-Sets a cmd2 parameter.  Accepts abbreviated parameter names so long
-as there is no ambiguity.  Call without arguments for a list of 
-settable parameters with their values.
-

Definition at line 1000 of file cmd2.py.

- -

References cmd2::cast(), do_show(), and settable.

-
01000 
-01001     def do_set(self, arg):
-01002         '''
-01003         Sets a cmd2 parameter.  Accepts abbreviated parameter names so long
-01004         as there is no ambiguity.  Call without arguments for a list of 
-01005         settable parameters with their values.'''
-01006         try:
-01007             statement, paramName, val = arg.parsed.raw.split(None, 2)
-01008             val = val.strip()
-01009             paramName = paramName.strip().lower()
-01010             if paramName not in self.settable:
-01011                 hits = [p for p in self.settable if p.startswith(paramName)]
-01012                 if len(hits) == 1:
-01013                     paramName = hits[0]
-01014                 else:
-01015                     return self.do_show(paramName)
-01016             currentVal = getattr(self, paramName)
-01017             if (val[0] == val[-1]) and val[0] in ("'", '"'):
-01018                 val = val[1:-1]
-01019             else:                
-01020                 val = cast(currentVal, val)
-01021             setattr(self, paramName, val)
-01022             self.stdout.write('%s - was: %s\nnow: %s\n' % (paramName, currentVal, val))
-01023             if currentVal != val:
-01024                 try:
-01025                     onchange_hook = getattr(self, '_onchange_%s' % paramName)
-01026                     onchange_hook(old=currentVal, new=val)
-01027                 except AttributeError:
-01028                     pass
-01029         except (ValueError, AttributeError, NotSettableError), e:
-01030             self.do_show(arg)
-                
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::do_shell ( self,
 arg 
)
-
-
- -

Definition at line 1035 of file cmd2.py.

-
01035 
-01036     def do_shell(self, arg):
-01037         'execute a command as if at the OS prompt.'
-01038         os.system(arg)
-                
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::do_shortcuts ( self,
 args 
)
-
-
-
Lists single-key shortcuts available.
-

Definition at line 479 of file cmd2.py.

- -

References shortcuts.

-
00479 
-00480     def do_shortcuts(self, args):
-00481         """Lists single-key shortcuts available."""
-00482         result = "\n".join('%s: %s' % (sc[0], sc[1]) for sc in sorted(self.shortcuts))
-00483         self.stdout.write("Single-key shortcuts for other commands:\n%s\n" % (result))
-
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::do_show ( self,
 arg,
 opts 
)
-
-
-
Shows value of a parameter.
-

Definition at line 982 of file cmd2.py.

- -

References cmd2::ljust(), poutput(), and settable.

- -

Referenced by do_set().

-
00982 
-00983     def do_show(self, arg, opts):
-00984         '''Shows value of a parameter.'''
-00985         param = arg.strip().lower()
-00986         result = {}
-00987         maxlen = 0
-00988         for p in self.settable:
-00989             if (not param) or p.startswith(param):
-00990                 result[p] = '%s: %s' % (p, str(getattr(self, p)))
-00991                 maxlen = max(maxlen, len(result[p]))
-00992         if result:
-00993             for p in sorted(result):
-00994                 if opts.long:
-00995                     self.poutput('%s # %s' % (result[p].ljust(maxlen), self.settable[p]))
-00996                 else:
-00997                     self.poutput(result[p])
-00998         else:
-00999             raise NotImplementedError("Parameter '%s' not supported (type 'show' for list of parameters)." % param)
-    
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::fileimport ( self,
 statement,
 source 
)
-
-
- -

Definition at line 1258 of file cmd2.py.

-
01258 
-01259     def fileimport(self, statement, source):
-01260         try:
-01261             f = open(os.path.expanduser(source))
-01262         except IOError:
-01263             self.stdout.write("Couldn't read from file %s\n" % source)
-01264             return ''
-01265         data = f.read()
-01266         f.close()
-01267         return data
-
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::func_named ( self,
 arg 
)
-
-
- -

Definition at line 755 of file cmd2.py.

- -

References abbrev, and keywords.

- -

Referenced by do_help().

-
00755 
-00756     def func_named(self, arg):
-00757         result = None
-00758         target = 'do_' + arg
-00759         if target in dir(self):
-00760             result = target
-00761         else:
-00762             if self.abbrev:   # accept shortened versions of commands
-00763                 funcs = [fname for fname in self.keywords if fname.startswith(arg)]
-00764                 if len(funcs) == 1:
-00765                     result = 'do_' + funcs[0]
-        return result
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::last_matching ( self,
 arg 
)
-
-
- -

Definition at line 1100 of file cmd2.py.

- -

References history.

- -

Referenced by do_ed(), and do_run().

-
01100 
-01101     def last_matching(self, arg):
-01102         try:
-01103             if arg:
-01104                 return self.history.get(arg)[-1]
-01105             else:
-01106                 return self.history[-1]
-01107         except IndexError:
-            return None        
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::onecmd ( self,
 line 
)
-
-
-
Interpret the argument as though it had been typed in response
-to the prompt.
-
-This may be overridden, but should not normally need to be;
-see the precmd() and postcmd() methods for useful execution hooks.
-The return value is a flag indicating whether interpretation of
-commands by the interpreter should stop.
-
-This (`cmd2`) version of `onecmd` already override's `cmd`'s `onecmd`.
-
-
-

Definition at line 844 of file cmd2.py.

- -

Referenced by onecmd_plus_hooks().

-
00844 
-00845     def onecmd(self, line):
-00846         """Interpret the argument as though it had been typed in response
-00847         to the prompt.
-00848 
-00849         This may be overridden, but should not normally need to be;
-00850         see the precmd() and postcmd() methods for useful execution hooks.
-00851         The return value is a flag indicating whether interpretation of
-00852         commands by the interpreter should stop.
-00853         
-00854         This (`cmd2`) version of `onecmd` already override's `cmd`'s `onecmd`.
-00855 
-00856         """
-00857         statement = self.parsed(line)
-00858         self.lastcmd = statement.parsed.raw   
-00859         funcname = self.func_named(statement.parsed.command)
-00860         if not funcname:
-00861             return self._default(statement)
-00862         try:
-00863             func = getattr(self, funcname)
-00864         except AttributeError:
-00865             return self._default(statement)
-00866         stop = func(statement) 
-00867         return stop                
-        
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::onecmd_plus_hooks ( self,
 line 
)
-
-
- -

Definition at line 766 of file cmd2.py.

- -

References complete_statement(), excludeFromHistory, onecmd(), perror(), pfeedback(), pirate3::Pirate::postcmd(), pirate4::Pirate::postcmd(), pirate5::Pirate::postcmd(), pirate7::Pirate::postcmd(), pirate8::Pirate::postcmd(), pirate6::Pirate::postcmd(), postparsing_postcmd(), postparsing_precmd(), pirate3::Pirate::precmd(), pirate4::Pirate::precmd(), pirate5::Pirate::precmd(), pirate7::Pirate::precmd(), pirate8::Pirate::precmd(), pirate6::Pirate::precmd(), redirect_output(), restore_output(), and timing.

- -

Referenced by do_py(), do_run(), and run_commands_at_invocation().

-
00766 
-00767     def onecmd_plus_hooks(self, line):
-00768         # The outermost level of try/finally nesting can be condensed once
-00769         # Python 2.4 support can be dropped.
-00770         stop = 0
-00771         try:
-00772             try:
-00773                 statement = self.complete_statement(line)
-00774                 (stop, statement) = self.postparsing_precmd(statement)
-00775                 if stop:
-00776                     return self.postparsing_postcmd(stop)
-00777                 if statement.parsed.command not in self.excludeFromHistory:
-00778                     self.history.append(statement.parsed.raw)      
-00779                 try:
-00780                     self.redirect_output(statement)
-00781                     timestart = datetime.datetime.now()
-00782                     statement = self.precmd(statement)
-00783                     stop = self.onecmd(statement)
-00784                     stop = self.postcmd(stop, statement)
-00785                     if self.timing:
-00786                         self.pfeedback('Elapsed: %s' % str(datetime.datetime.now() - timestart))
-00787                 finally:
-00788                     self.restore_output(statement)
-00789             except EmptyStatement:
-00790                 return 0
-00791             except Exception, e:
-00792                 self.perror(str(e), statement)            
-00793         finally:
-            return self.postparsing_postcmd(stop)        
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::parsed ( self,
 raw,
 kwargs 
)
-
-
- -

Definition at line 726 of file cmd2.py.

- -

References parsed(), postparse(), preparse(), and shortcuts.

- -

Referenced by complete_statement(), cmd2::ParsedString::full_parsed_statement(), parsed(), and cmd2::ParsedString::with_args_replaced().

-
00726 
-00727     def parsed(self, raw, **kwargs):
-00728         if isinstance(raw, ParsedString):
-00729             p = raw
-00730         else:
-00731             # preparse is an overridable hook; default makes no changes
-00732             s = self.preparse(raw, **kwargs)
-00733             s = self.inputParser.transformString(s.lstrip())
-00734             s = self.commentGrammars.transformString(s)
-00735             for (shortcut, expansion) in self.shortcuts:
-00736                 if s.lower().startswith(shortcut):
-00737                     s = s.replace(shortcut, expansion + ' ', 1)
-00738                     break
-00739             result = self.parser.parseString(s)
-00740             result['raw'] = raw            
-00741             result['command'] = result.multilineCommand or result.command        
-00742             result = self.postparse(result)
-00743             p = ParsedString(result.args)
-00744             p.parsed = result
-00745             p.parser = self.parsed
-00746         for (key, val) in kwargs.items():
-00747             p.parsed[key] = val
-00748         return p
-              
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::perror ( self,
 errmsg,
 statement = None 
)
-
-
- -

Definition at line 404 of file cmd2.py.

- -

References debug.

- -

Referenced by do_py(), do_save(), and onecmd_plus_hooks().

-
00404 
-00405     def perror(self, errmsg, statement=None):
-00406         if self.debug:
-00407             traceback.print_exc()
-        print (str(errmsg))
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::pfeedback ( self,
 msg 
)
-
-
-
For printing nonessential feedback.  Can be silenced with `quiet`.
-   Inclusion in redirected output is controlled by `feedback_to_output`.
-

Definition at line 408 of file cmd2.py.

- -

References feedback_to_output, poutput(), and quiet.

- -

Referenced by do_run(), do_save(), and onecmd_plus_hooks().

-
00408 
-00409     def pfeedback(self, msg):
-00410         """For printing nonessential feedback.  Can be silenced with `quiet`.
-00411            Inclusion in redirected output is controlled by `feedback_to_output`."""
-00412         if not self.quiet:
-00413             if self.feedback_to_output:
-00414                 self.poutput(msg)
-00415             else:
-                print (msg)
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::postparse ( self,
 parseResult 
)
-
-
- -

Definition at line 723 of file cmd2.py.

- -

Referenced by parsed().

-
00723 
-00724     def postparse(self, parseResult):
-00725         return parseResult
-   
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::postparsing_postcmd ( self,
 stop 
)
-
-
- -

Definition at line 752 of file cmd2.py.

- -

Referenced by _default(), and onecmd_plus_hooks().

-
00752 
-00753     def postparsing_postcmd(self, stop):
-00754         return stop
-    
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::postparsing_precmd ( self,
 statement 
)
-
-
- -

Definition at line 749 of file cmd2.py.

- -

Referenced by onecmd_plus_hooks().

-
00749 
-00750     def postparsing_precmd(self, statement):
-00751         stop = 0
-        return stop, statement
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::poutput ( self,
 msg 
)
-
-
-
Convenient shortcut for self.stdout.write(); adds newline if necessary.
-

Definition at line 398 of file cmd2.py.

- -

Referenced by do_history(), do_list(), do_show(), pfeedback(), and select().

-
00398 
-00399     def poutput(self, msg):
-00400         '''Convenient shortcut for self.stdout.write(); adds newline if necessary.'''
-00401         if msg:
-00402             self.stdout.write(msg)
-00403             if msg[-1] != '\n':
-                self.stdout.write('\n')
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::preparse ( self,
 raw,
 kwargs 
)
-
-
- -

Definition at line 721 of file cmd2.py.

- -

Referenced by parsed().

-
00721 
-00722     def preparse(self, raw, **kwargs):
-        return raw
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::pseudo_raw_input ( self,
 prompt 
)
-
-
-
copied from cmd's cmdloop; like raw_input, but accounts for changed stdin, stdout
-

Definition at line 876 of file cmd2.py.

- -

References use_rawinput.

- -

Referenced by complete_statement().

-
00876 
-00877     def pseudo_raw_input(self, prompt):
-00878         """copied from cmd's cmdloop; like raw_input, but accounts for changed stdin, stdout"""
-00879         
-00880         if self.use_rawinput:
-00881             try:
-00882                 line = raw_input(prompt)
-00883             except EOFError:
-00884                 line = 'EOF'
-00885         else:
-00886             self.stdout.write(prompt)
-00887             self.stdout.flush()
-00888             line = self.stdin.readline()
-00889             if not len(line):
-00890                 line = 'EOF'
-00891             else:
-00892                 if line[-1] == '\n': # this was always true in Cmd
-00893                     line = line[:-1] 
-00894         return line
-    
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::read_file_or_url ( self,
 fname 
)
-
-
- -

Definition at line 1189 of file cmd2.py.

- -

References defaultExtension.

-
01189 
-01190     def read_file_or_url(self, fname):
-01191         # TODO: not working on localhost
-01192         if isinstance(fname, file):
-01193             result = open(fname, 'r')
-01194         else:
-01195             match = self.urlre.match(fname)
-01196             if match:
-01197                 result = urllib.urlopen(match.group(1))
-01198             else:
-01199                 fname = os.path.expanduser(fname)
-01200                 try:
-01201                     result = open(os.path.expanduser(fname), 'r')
-01202                 except IOError:                    
-01203                     result = open('%s.%s' % (os.path.expanduser(fname), 
-01204                                              self.defaultExtension), 'r')
-01205         return result
-        
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::redirect_output ( self,
 statement 
)
-
-
- -

Definition at line 809 of file cmd2.py.

- -

References cmd2::get_paste_buffer(), kept_state, kept_sys, redirect, redirector, and stdout.

- -

Referenced by onecmd_plus_hooks().

-
00809 
-00810     def redirect_output(self, statement):
-00811         if statement.parsed.pipeTo:
-00812             self.kept_state = Statekeeper(self, ('stdout',))
-00813             self.kept_sys = Statekeeper(sys, ('stdout',))
-00814             self.redirect = subprocess.Popen(statement.parsed.pipeTo, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
-00815             sys.stdout = self.stdout = self.redirect.stdin
-00816         elif statement.parsed.output:
-00817             if (not statement.parsed.outputTo) and (not can_clip):
-00818                 raise EnvironmentError('Cannot redirect to paste buffer; install ``xclip`` and re-run to enable')
-00819             self.kept_state = Statekeeper(self, ('stdout',))            
-00820             self.kept_sys = Statekeeper(sys, ('stdout',))
-00821             if statement.parsed.outputTo:
-00822                 mode = 'w'
-00823                 if statement.parsed.output == 2 * self.redirector:
-00824                     mode = 'a'
-00825                 sys.stdout = self.stdout = open(os.path.expanduser(statement.parsed.outputTo), mode)                            
-00826             else:
-00827                 sys.stdout = self.stdout = tempfile.TemporaryFile(mode="w+")
-00828                 if statement.parsed.output == '>>':
-00829                     self.stdout.write(get_paste_buffer())
-                    
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::restore_output ( self,
 statement 
)
-
-
- -

Definition at line 830 of file cmd2.py.

- -

References kept_state, and cmd2::write_to_paste_buffer.

- -

Referenced by onecmd_plus_hooks().

-
00830 
-00831     def restore_output(self, statement):
-00832         if self.kept_state:
-00833             if statement.parsed.output:
-00834                 if not statement.parsed.outputTo:
-00835                     self.stdout.seek(0)
-00836                     write_to_paste_buffer(self.stdout.read())
-00837             elif statement.parsed.pipeTo:
-00838                 for result in self.redirect.communicate():              
-00839                     self.kept_state.stdout.write(result or '')                        
-00840             self.stdout.close()
-00841             self.kept_state.restore()  
-00842             self.kept_sys.restore()
-00843             self.kept_state = None                        
-                        
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::run_commands_at_invocation ( self,
 callargs 
)
-
-
- -

Definition at line 1278 of file cmd2.py.

- -

References _STOP_AND_EXIT, and onecmd_plus_hooks().

- -

Referenced by cmdloop().

-
01278 
-01279     def run_commands_at_invocation(self, callargs):
-01280         for initial_command in callargs:
-01281             if self.onecmd_plus_hooks(initial_command + '\n'):
-01282                 return self._STOP_AND_EXIT
-
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::runTranscriptTests ( self,
 callargs 
)
-
-
- -

Definition at line 1268 of file cmd2.py.

- -

Referenced by cmdloop().

-
01268 
-01269     def runTranscriptTests(self, callargs):
-01270         class TestMyAppCase(Cmd2TestCase):
-01271             CmdApp = self.__class__        
-01272         self.__class__.testfiles = callargs
-01273         sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main()
-01274         testcase = TestMyAppCase()
-01275         runner = unittest.TextTestRunner()
-01276         result = runner.run(testcase)
-01277         result.printErrors()
-
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
def cmd2::Cmd::select ( self,
 options,
 prompt = 'Your choice? ' 
)
-
-
-
Presents a numbered menu to the user.  Modelled after
-   the bash shell's SELECT.  Returns the item chosen.
-   
-   Argument ``options`` can be:
-
-     | a single string -> will be split into one-word options
-     | a list of strings -> will be offered as options
-     | a list of tuples -> interpreted as (value, text), so 
-                   that the return value can differ from
-                   the text advertised to the user 
-

Definition at line 946 of file cmd2.py.

- -

References cmd2::options(), and poutput().

-
00946 
-00947     def select(self, options, prompt='Your choice? '):
-00948         '''Presents a numbered menu to the user.  Modelled after
-00949            the bash shell's SELECT.  Returns the item chosen.
-00950            
-00951            Argument ``options`` can be:
-00952 
-00953              | a single string -> will be split into one-word options
-00954              | a list of strings -> will be offered as options
-00955              | a list of tuples -> interpreted as (value, text), so 
-00956                                    that the return value can differ from
-00957                                    the text advertised to the user '''
-00958         if isinstance(options, basestring):
-00959             options = zip(options.split(), options.split())
-00960         fulloptions = []
-00961         for opt in options:
-00962             if isinstance(opt, basestring):
-00963                 fulloptions.append((opt, opt))
-00964             else:
-00965                 try:
-00966                     fulloptions.append((opt[0], opt[1]))
-00967                 except IndexError:
-00968                     fulloptions.append((opt[0], opt[0]))
-00969         for (idx, (value, text)) in enumerate(fulloptions):
-00970             self.poutput('  %2d. %s\n' % (idx+1, text))
-00971         while True:
-00972             response = raw_input(prompt)
-00973             try:
-00974                 response = int(response)
-00975                 result = fulloptions[response - 1][0]
-00976                 break
-00977             except ValueError:
-00978                 pass # loop and ask again
-00979         return result
-    
-
-
-
-

Member Data Documentation

- -
-
- - - - -
cmd2::Cmd::_STOP_AND_EXIT = True [static, private]
-
-
- -

Definition at line 416 of file cmd2.py.

- -

Referenced by do_quit(), and run_commands_at_invocation().

- -
-
- -
-
- - - - -
int cmd2::Cmd::_STOP_SCRIPT_NO_EXIT = 999 [static, private]
-
-
- -

Definition at line 417 of file cmd2.py.

- -

Referenced by do_EOF().

- -
-
- -
-
- - - - -
cmd2::Cmd::abbrev = True [static]
-
-
- -

Definition at line 374 of file cmd2.py.

- -

Referenced by func_named().

- -
-
- -
-
- - - - -
cmd2::Cmd::blankLinesAllowed = False [static]
-
-
- -

Definition at line 490 of file cmd2.py.

- -
-
- -
- -
- -

Definition at line 667 of file cmd2.py.

- -
-
- -
- -
- -

Definition at line 667 of file cmd2.py.

- -
-
- -
-
- - - - -
cmd2::Cmd::case_insensitive = True [static]
-
-
- -

Definition at line 363 of file cmd2.py.

- -

Referenced by do_cmdenvironment().

- -
-
- -
-
- - - - -
dictionary cmd2::Cmd::colorcodes [static]
-
-
-Initial value:
{'bold':{True:'\x1b[1m',False:'\x1b[22m'},
-                  'cyan':{True:'\x1b[36m',False:'\x1b[39m'},
-                  'blue':{True:'\x1b[34m',False:'\x1b[39m'},
-                  'red':{True:'\x1b[31m',False:'\x1b[39m'},
-                  'magenta':{True:'\x1b[35m',False:'\x1b[39m'},
-                  'green':{True:'\x1b[32m',False:'\x1b[39m'},
-                  'underline':{True:'\x1b[4m',False:'\x1b[24m'}}
-
-

Definition at line 427 of file cmd2.py.

- -
-
- -
-
- - - - -
tuple cmd2::Cmd::colors = (platform.system() != 'Windows') [static]
-
-
- -

Definition at line 434 of file cmd2.py.

- -
-
- -
-
- - - - -
tuple cmd2::Cmd::commentGrammars = pyparsing.Or([pyparsing.pythonStyleComment, pyparsing.cStyleComment]) [static]
-
-
- -

Definition at line 485 of file cmd2.py.

- -

Referenced by complete_statement().

- -
-
- -
-
- - - - -
tuple cmd2::Cmd::commentInProgress = pyparsing.Literal('/*') [static]
-
-
- -

Definition at line 487 of file cmd2.py.

- -
-
- -
-
- - - - -
string cmd2::Cmd::continuation_prompt = '> ' [static]
-
-
- -

Definition at line 364 of file cmd2.py.

- -

Referenced by complete_statement().

- -
-
- -
- -
- -

Definition at line 1218 of file cmd2.py.

- -
-
- -
-
- - - - -
cmd2::Cmd::current_script_dir = None [static]
-
-
- -

Definition at line 375 of file cmd2.py.

- -

Referenced by do__relative_load().

- -
-
- -
-
- - - - -
cmd2::Cmd::debug = False [static]
-
-
- -

Definition at line 379 of file cmd2.py.

- -

Referenced by perror().

- -
-
- -
-
- - - - -
string cmd2::Cmd::default_file_name = 'command.txt' [static]
-
-
- -

Definition at line 373 of file cmd2.py.

- -

Referenced by do_ed(), and do_save().

- -
-
- -
-
- - - - -
cmd2::Cmd::default_to_shell = False [static]
-
-
- -

Reimplemented in pirate7::Pirate, and pirate8::Pirate.

- -

Definition at line 370 of file cmd2.py.

- -

Referenced by _default().

- -
-
- -
-
- - - - -
string cmd2::Cmd::defaultExtension = 'txt' [static]
-
-
- -

Definition at line 372 of file cmd2.py.

- -

Referenced by read_file_or_url().

- -
-
- -
-
- - - - -
cmd2::Cmd::do__load = do_load [static]
-
-
- -

Definition at line 1241 of file cmd2.py.

- -

Referenced by do__relative_load(), and do_ed().

- -
-
- -
-
- - - - -
cmd2::Cmd::do_edit = do_ed [static]
-
-
- -

Definition at line 1155 of file cmd2.py.

- -
-
- -
-
- - - - -
cmd2::Cmd::do_eof = do_EOF [static]
-
-
- -

Definition at line 939 of file cmd2.py.

- -
-
- -
-
- - - - -
cmd2::Cmd::do_exit = do_quit [static]
-
-
- -

Definition at line 943 of file cmd2.py.

- -
-
- -
-
- - - - -
cmd2::Cmd::do_hi = do_history [static]
-
-
- -

Definition at line 1124 of file cmd2.py.

- -
-
- -
-
- - - - -
cmd2::Cmd::do_l = do_list [static]
-
-
- -

Definition at line 1125 of file cmd2.py.

- -
-
- -
-
- - - - -
cmd2::Cmd::do_li = do_list [static]
-
-
- -

Definition at line 1126 of file cmd2.py.

- -
-
- -
-
- - - - -
cmd2::Cmd::do_q = do_quit [static]
-
-
- -

Definition at line 944 of file cmd2.py.

- -
-
- -
-
- - - - -
cmd2::Cmd::do_r = do_run [static]
-
-
- -

Definition at line 1256 of file cmd2.py.

- -
-
- -
-
- - - - -
cmd2::Cmd::echo = False [static]
-
-
- -

Definition at line 362 of file cmd2.py.

- -
-
- -
-
- - - - -
tuple cmd2::Cmd::editor = os.environ.get('EDITOR') [static]
-
-
- -

Definition at line 418 of file cmd2.py.

- -

Referenced by do_ed().

- -
-
- -
-
- - - - -
string cmd2::Cmd::editor = 'notepad' [static]
-
-
- -

Definition at line 421 of file cmd2.py.

- -
-
- -
-
- - - - -
string cmd2::Cmd::excludeFromHistory = '''run r list l history hi ed edit li eof''' [static]
-
-
- -

Definition at line 369 of file cmd2.py.

- -

Referenced by onecmd_plus_hooks().

- -
-
- -
-
- - - - -
cmd2::Cmd::feedback_to_output = False [static]
-
-
- -

Definition at line 377 of file cmd2.py.

- -

Referenced by pfeedback().

- -
-
- -
-
- - - - -
string cmd2::Cmd::help = "describe function of parameter" [static]
-
-
- -

Reimplemented in pirate8::Pirate.

- -

Definition at line 981 of file cmd2.py.

- -
-
- -
-
- - - - -
cmd2::Cmd::history
-
-
- -

Definition at line 469 of file cmd2.py.

- -

Referenced by do_ed(), do_history(), do_save(), and last_matching().

- -
-
- -
- -
- -

Definition at line 469 of file cmd2.py.

- -
-
- -
- -
- -

Definition at line 667 of file cmd2.py.

- -
-
- -
-
- - - - -
cmd2::Cmd::intro
-
-
- -

Definition at line 898 of file cmd2.py.

- -
-
- -
-
- - - - -
cmd2::Cmd::kept_state = None [static]
-
-
- -

Definition at line 381 of file cmd2.py.

- -

Referenced by redirect_output(), and restore_output().

- -
-
- -
-
- - - - -
cmd2::Cmd::kept_sys
-
-
- -

Definition at line 809 of file cmd2.py.

- -

Referenced by redirect_output().

- -
-
- -
-
- - - - -
cmd2::Cmd::keywords
-
-
- -

Definition at line 469 of file cmd2.py.

- -

Referenced by func_named().

- -
-
- -
-
- - - - -
cmd2::Cmd::lastcmd
-
-
- -

Definition at line 854 of file cmd2.py.

- -
-
- -
-
- - - - -
string cmd2::Cmd::legalChars = u'!#$%.:?@_' [static]
-
-
- -

Definition at line 367 of file cmd2.py.

- -
-
- -
-
- - - - -
cmd2::Cmd::locals_in_py = True [static]
-
-
- -

Definition at line 380 of file cmd2.py.

- -

Referenced by do_py().

- -
-
- -
- -
- -

Definition at line 667 of file cmd2.py.

- -
-
- -
-
- - - - -
list cmd2::Cmd::multilineCommands = [] [static]
-
-
- -

Reimplemented in pirate7::Pirate, pirate8::Pirate, and example::CmdLineApp.

- -

Definition at line 491 of file cmd2.py.

- -
-
- -
- -
- -

Definition at line 667 of file cmd2.py.

- -
-
- -
-
- - - - -
string cmd2::Cmd::noSpecialParse = 'set ed edit exit' [static]
-
-
- -

Definition at line 371 of file cmd2.py.

- -
-
- -
- -
- -

Definition at line 898 of file cmd2.py.

- -
-
- -
-
- - - - -
cmd2::Cmd::parser
-
-
- -

Definition at line 667 of file cmd2.py.

- -

Referenced by cmd2::ParsedString::full_parsed_statement(), and cmd2::ParsedString::with_args_replaced().

- -
-
- -
-
- - - - -
tuple cmd2::Cmd::prefixParser = pyparsing.Empty() [static]
-
-
- -

Definition at line 484 of file cmd2.py.

- -
-
- -
-
- - - - -
cmd2::Cmd::prompt
-
-
- -

Reimplemented in pirate6::Pirate, pirate7::Pirate, and pirate8::Pirate.

- -

Definition at line 1218 of file cmd2.py.

- -
-
- -
-
- - - - -
cmd2::Cmd::pystate
-
-
- -

Definition at line 469 of file cmd2.py.

- -

Referenced by do_py().

- -
-
- -
-
- - - - -
cmd2::Cmd::quiet = False [static]
-
-
- -

Definition at line 378 of file cmd2.py.

- -

Referenced by pfeedback().

- -
-
- -
-
- - - - -
cmd2::Cmd::redirect
-
-
- -

Definition at line 809 of file cmd2.py.

- -

Referenced by redirect_output().

- -
-
- -
-
- - - - -
string cmd2::Cmd::redirector = '>' [static]
-
-
- -

Reimplemented in example::CmdLineApp.

- -

Definition at line 382 of file cmd2.py.

- -

Referenced by redirect_output().

- -
-
- -
-
- - - - -
list cmd2::Cmd::reserved_words = [] [static]
-
-
- -

Definition at line 376 of file cmd2.py.

- -
-
- -
-
- - - - -
tuple cmd2::Cmd::saveparser [static]
-
-
-Initial value:
(pyparsing.Optional(pyparsing.Word(pyparsing.nums)^'*')("idx") + 
-                  pyparsing.Optional(pyparsing.Word(legalChars + '/\\'))("fname") +
-                  pyparsing.stringEnd)
-
-

Definition at line 1157 of file cmd2.py.

- -
-
- -
-
- - - - -
tuple cmd2::Cmd::settable [static]
-
-
-Initial value:
stubbornDict('''
-    prompt
-    colors                Colorized output (*nix only)
-    continuation_prompt   On 2nd+ line of input
-    debug                 Show full error stack on error
-    default_file_name     for ``save``, ``load``, etc.
-    editor                Program used by ``edit``      
-    case_insensitive      upper- and lower-case both OK
-    feedback_to_output    include nonessentials in `|`, `>` results 
-    quiet                 Don't print nonessential feedback
-    echo                  Echo command issued into output
-    timing                Report execution times
-    abbrev                Accept abbreviated commands
-    ''')
-
-

Reimplemented in pirate7::Pirate, and pirate8::Pirate.

- -

Definition at line 383 of file cmd2.py.

- -

Referenced by do_cmdenvironment(), do_set(), and do_show().

- -
-
- -
-
- - - - -
dictionary cmd2::Cmd::shortcuts = {'?': 'help', '!': 'shell', '@': 'load', '@@': '_relative_load'} [static]
-
-
- -

Definition at line 368 of file cmd2.py.

- -

Referenced by do_shortcuts(), and parsed().

- -
-
- -
- -
- -

Definition at line 469 of file cmd2.py.

- -
-
- -
- -
- -

Definition at line 667 of file cmd2.py.

- -
-
- -
-
- - - - -
cmd2::Cmd::stdin
-
-
- -

Definition at line 1218 of file cmd2.py.

- -

Referenced by do_py().

- -
-
- -
-
- - - - -
cmd2::Cmd::stdout
-
-
- -

Definition at line 440 of file cmd2.py.

- -

Referenced by do_help(), do_py(), and redirect_output().

- -
-
- -
-
- - - - -
list cmd2::Cmd::terminators = [';'] [static]
-
-
- -

Reimplemented in pirate7::Pirate, and pirate8::Pirate.

- -

Definition at line 489 of file cmd2.py.

- -

Referenced by do_cmdenvironment().

- -
-
- -
-
- - - - -
cmd2::Cmd::timing = False [static]
-
-
- -

Definition at line 365 of file cmd2.py.

- -

Referenced by onecmd_plus_hooks().

- -
-
- -
-
- - - - -
tuple cmd2::Cmd::urlre = re.compile('(https?://[-\\w\\./]+)') [static]
-
-
- -

Definition at line 1217 of file cmd2.py.

- -
-
- -
- -
- -

Definition at line 1218 of file cmd2.py.

- -

Referenced by pseudo_raw_input().

- -
-
-
The documentation for this class was generated from the following file:
    -
  • /Users/amrogers/Developer/Projects/cmd2/cmd2.py
  • -
-
-
- - - - - -- cgit v1.2.1