tools/site_compare/command_line.py
def ParseCommandLine(self, argv=None, prog=None, execute=True):
    """Does the work of parsing a command line.

    Args:
      argv:     list of arguments, defaults to sys.args[1:]
      prog:     name of the command, defaults to the base name of the script
      execute:  if false, just parse, don't invoke the 'impl' member

    Returns:
      The command that was executed
    """
    if argv is None: argv = sys.argv[1:]
    if prog is None: prog = os.path.basename(sys.argv[0]).split('.')[0]

    # Store off our parameters, we may need them someday
    self.argv = argv
    self.prog = prog

    # We shouldn't be invoked without arguments, that's just lame
    if not len(argv):
      self.out.writelines(self.GetUsageString())
      self.Exit()
      return None   # in case the client overrides Exit

    # Is it a valid command?
    self.command_string = argv[0].lower()
    if not self.command_string in self.cmd_dict:
      self.err.write("Unknown command: '%s'\n\n" % self.command_string)
      self.out.write(self.GetUsageString())
      self.Exit()
      return None   # in case the client overrides Exit

    self.command = self.cmd_dict[self.command_string]

    # "rargs" = remaining (unparsed) arguments
    # "largs" = already parsed, "left" of the read head
    self.rargs = argv[1:]
    self.largs = []

    # let the command object do the parsing
    self.command.ParseArguments()

    if self.command.parse_errors:
      # there were errors, output the usage string and exit
      self.err.write(self.command.GetUsageString()+"\n\n")
      self.err.write("\n".join(self.command.parse_errors))
      self.err.write("\n\n")

      self.Exit()

    elif execute and self.command.impl:
      self.command.impl(self.command)

    return self.command
Does the work of parsing a command line.

    Args:
      argv:     list of arguments, defaults to sys.args[1:]
      prog:     name of the command, defaults to the base name of the script
      execute:  if false, just parse, don't invoke the 'impl' member

    Returns:
      The command that was executed
    
Does the work of parsing a command line.
Does the work of parsing a command line .
def ParseCommandLine(self, argv=None, prog=None, execute=True):
    if argv is None: argv = sys.argv[1:]
    if prog is None: prog = os.path.basename(sys.argv[0]).split('.')[0]
    self.argv = argv
    self.prog = prog
    if not len(argv):
      self.out.writelines(self.GetUsageString())
      self.Exit()
      return None   
    self.command_string = argv[0].lower()
    if not self.command_string in self.cmd_dict:
      self.err.write("Unknown command: '%s'\n\n" % self.command_string)
      self.out.write(self.GetUsageString())
      self.Exit()
      return None   
    self.command = self.cmd_dict[self.command_string]
    self.rargs = argv[1:]
    self.largs = []
    self.command.ParseArguments()
    if self.command.parse_errors:
      self.err.write(self.command.GetUsageString()+"\n\n")
      self.err.write("\n".join(self.command.parse_errors))
      self.err.write("\n\n")
      self.Exit()
    elif execute and self.command.impl:
      self.command.impl(self.command)
    return self.command
def ParseCommandLine ( self , argv = None , prog = None , execute = True ) : if argv is None : argv = sys . argv [ 1 : ] if prog is None : prog = os . path . basename ( sys . argv [ 0 ] ) . split ( '.' ) [ 0 ] self . argv = argv self . prog = prog if not len ( argv ) : self . out . writelines ( self . GetUsageString ( ) ) self . Exit ( ) return None self . command_string = argv [ 0 ] . lower ( ) if not self . command_string in self . cmd_dict : self . err . write ( "Unknown command: '%s'\n\n" % self . command_string ) self . out . write ( self . GetUsageString ( ) ) self . Exit ( ) return None self . command = self . cmd_dict [ self . command_string ] self . rargs = argv [ 1 : ] self . largs = [ ] self . command . ParseArguments ( ) if self . command . parse_errors : self . err . write ( self . command . GetUsageString ( ) + "\n\n" ) self . err . write ( "\n" . join ( self . command . parse_errors ) ) self . err . write ( "\n\n" ) self . Exit ( ) elif execute and self . command . impl : self . command . impl ( self . command ) return self . command
Does the work of parsing a command line.
Does the work of parsing a command line .
"""Does the work of parsing a command line.

    Args:
      argv:     list of arguments, defaults to sys.args[1:]
      prog:     name of the command, defaults to the base name of the script
      execute:  if false, just parse, don't invoke the 'impl' member

    Returns:
      The command that was executed
    """ # Store off our parameters, we may need them someday # We shouldn't be invoked without arguments, that's just lame # in case the client overrides Exit # Is it a valid command? # in case the client overrides Exit # "rargs" = remaining (unparsed) arguments # "largs" = already parsed, "left" of the read head # let the command object do the parsing # there were errors, output the usage string and exit
The command that was executed
The command that was executed
self
argv
list of arguments, defaults to sys.args[1:]
list of arguments defaults to sys . args [ 1 : ]
prog
name of the command, defaults to the base name of the script
name of the command defaults to the base name of the script
execute
if false, just parse, don't invoke the 'impl' member
if false just parse don ' t invoke the ' impl ' member