tools/site_compare/command_line.py
def StringToValue(self, value, type, argstr):
    """Convert a string from the command line to a value type."""
    try:
      if type == 'string':
        pass  # leave it be

      elif type == 'int':
        try:
          value = int(value)
        except ValueError:
          raise ParseError

      elif type == 'readfile':
        if not os.path.isfile(value):
          raise ParseError("'%s': '%s' does not exist" % (argstr, value))

      elif type == 'coords':
        try:
          value = [int(val) for val in
                   re.match("\(\s*(\d+)\s*\,\s*(\d+)\s*\)\s*\Z", value).
                   groups()]
        except AttributeError:
          raise ParseError

      else:
        raise ValueError("Unknown type: '%s'" % type)

    except ParseError, e:
      # The bare exception is raised in the generic case; more specific errors
      # will arrive with arguments and should just be reraised
      if not e.args:
        e = ParseError("'%s': unable to convert '%s' to type '%s'" %
                       (argstr, value, type))
      raise e

    return value
Convert a string from the command line to a value type.
Convert a string from the command line to a value type.
Convert a string from the command line to a value type .
def StringToValue(self, value, type, argstr):
    try:
      if type == 'string':
        pass  
      elif type == 'int':
        try:
          value = int(value)
        except ValueError:
          raise ParseError
      elif type == 'readfile':
        if not os.path.isfile(value):
          raise ParseError("'%s': '%s' does not exist" % (argstr, value))
      elif type == 'coords':
        try:
          value = [int(val) for val in
                   re.match("\(\s*(\d+)\s*\,\s*(\d+)\s*\)\s*\Z", value).
                   groups()]
        except AttributeError:
          raise ParseError
      else:
        raise ValueError("Unknown type: '%s'" % type)
    except ParseError, e:
      if not e.args:
        e = ParseError("'%s': unable to convert '%s' to type '%s'" %
                       (argstr, value, type))
      raise e
    return value
def StringToValue ( self , value , type , argstr ) : try : if type == 'string' : pass elif type == 'int' : try : value = int ( value ) except ValueError : raise ParseError elif type == 'readfile' : if not os . path . isfile ( value ) : raise ParseError ( "'%s': '%s' does not exist" % ( argstr , value ) ) elif type == 'coords' : try : value = [ int ( val ) for val in re . match ( "\(\s*(\d+)\s*\,\s*(\d+)\s*\)\s*\Z" , value ) . groups ( ) ] except AttributeError : raise ParseError else : raise ValueError ( "Unknown type: '%s'" % type ) except ParseError , e : if not e . args : e = ParseError ( "'%s': unable to convert '%s' to type '%s'" % ( argstr , value , type ) ) raise e return value
Convert a string from the command line to a value type.
Convert a string from the command line to a value type .
"""Convert a string from the command line to a value type.""" # leave it be # The bare exception is raised in the generic case; more specific errors # will arrive with arguments and should just be reraised
self
value
type
argstr