parameters: ()
return_statement: return {'input': input_file,
              'output': options.filename,
              'safe_mode': options.safe,
              'extensions': options.extensions,
              'encoding': options.encoding,
              'output_format': options.output_format}, options.verbose
docstring: Define and parse `optparse` options for command-line usage.
docstring_summary: Define and parse `optparse` options for command-line usage.
docstring_tokens: Define and parse optparse options for command - line usage .
function: def parse_options():
      """
      Define and parse `optparse` options for command-line usage.
      """
  
      try:
          optparse = __import__("optparse")
      except:
          if len(sys.argv) == 2:
              return {'input': sys.argv[1],
                      'output': None,
                      'safe': False,
                      'extensions': [],
                      'encoding': None }, CRITICAL
          else:
              print OPTPARSE_WARNING
              return None, None
  
      parser = optparse.OptionParser(usage="%prog INPUTFILE [options]")
      parser.add_option("-f", "--file", dest="filename", default=sys.stdout,
                        help="write output to OUTPUT_FILE",
                        metavar="OUTPUT_FILE")
      parser.add_option("-e", "--encoding", dest="encoding",
                        help="encoding for input and output files",)
      parser.add_option("-q", "--quiet", default = CRITICAL,
                        action="store_const", const=CRITICAL+10, dest="verbose",
                        help="suppress all messages")
      parser.add_option("-v", "--verbose",
                        action="store_const", const=INFO, dest="verbose",
                        help="print info messages")
      parser.add_option("-s", "--safe", dest="safe", default=False,
                        metavar="SAFE_MODE",
                        help="safe mode ('replace', 'remove' or 'escape'  user's HTML tag)")
      parser.add_option("-o", "--output_format", dest="output_format", 
                        default='xhtml1', metavar="OUTPUT_FORMAT",
                        help="Format of output. One of 'xhtml1' (default) or 'html4'.")
      parser.add_option("--noisy",
                        action="store_const", const=DEBUG, dest="verbose",
                        help="print debug messages")
      parser.add_option("-x", "--extension", action="append", dest="extensions",
                        help = "load extension EXTENSION", metavar="EXTENSION")
  
      (options, args) = parser.parse_args()
  
      if not len(args) == 1:
          parser.print_help()
          return None, None
      else:
          input_file = args[0]
  
      if not options.extensions:
          options.extensions = []
  
      return {'input': input_file,
              'output': options.filename,
              'safe_mode': options.safe,
              'extensions': options.extensions,
              'encoding': options.encoding,
              'output_format': options.output_format}, options.verbose
function_tokens: def parse_options ( ) : try : optparse = __import__ ( "optparse" ) except : if len ( sys . argv ) == 2 : return { 'input' : sys . argv [ 1 ] , 'output' : None , 'safe' : False , 'extensions' : [ ] , 'encoding' : None } , CRITICAL else : print OPTPARSE_WARNING return None , None parser = optparse . OptionParser ( usage = "%prog INPUTFILE [options]" ) parser . add_option ( "-f" , "--file" , dest = "filename" , default = sys . stdout , help = "write output to OUTPUT_FILE" , metavar = "OUTPUT_FILE" ) parser . add_option ( "-e" , "--encoding" , dest = "encoding" , help = "encoding for input and output files" , ) parser . add_option ( "-q" , "--quiet" , default = CRITICAL , action = "store_const" , const = CRITICAL + 10 , dest = "verbose" , help = "suppress all messages" ) parser . add_option ( "-v" , "--verbose" , action = "store_const" , const = INFO , dest = "verbose" , help = "print info messages" ) parser . add_option ( "-s" , "--safe" , dest = "safe" , default = False , metavar = "SAFE_MODE" , help = "safe mode ('replace', 'remove' or 'escape'  user's HTML tag)" ) parser . add_option ( "-o" , "--output_format" , dest = "output_format" , default = 'xhtml1' , metavar = "OUTPUT_FORMAT" , help = "Format of output. One of 'xhtml1' (default) or 'html4'." ) parser . add_option ( "--noisy" , action = "store_const" , const = DEBUG , dest = "verbose" , help = "print debug messages" ) parser . add_option ( "-x" , "--extension" , action = "append" , dest = "extensions" , help = "load extension EXTENSION" , metavar = "EXTENSION" ) ( options , args ) = parser . parse_args ( ) if not len ( args ) == 1 : parser . print_help ( ) return None , None else : input_file = args [ 0 ] if not options . extensions : options . extensions = [ ] return { 'input' : input_file , 'output' : options . filename , 'safe_mode' : options . safe , 'extensions' : options . extensions , 'encoding' : options . encoding , 'output_format' : options . output_format } , options . verbose