我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用dateutil.parser.add_option()。
def build_cli_parser(): parser = optparse.OptionParser(usage="%prog [options]", description="Dump sensor list") # for each supported output type, add an option # parser.add_option("-c", "--cburl", action="store", default=None, dest="url", help="CB server's URL. e.g., http://127.0.0.1 ") parser.add_option("-a", "--apitoken", action="store", default=None, dest="token", help="API Token for Carbon Black server") parser.add_option("-n", "--no-ssl-verify", action="store_false", default=True, dest="ssl_verify", help="Do not verify server SSL certificate.") parser.add_option("-f", "--format", action="store", default='plain', dest="format", help="Output in pipe-delimited ('pipe'), plaintext ('plain') format or csv ('csv'); plain by default") parser.add_option("-g", "--group", action="store", default=None, dest="groupid", help="Limit sensor listing to just those specified by the sensor group id provided") parser.add_option("-t", "--hours", action="store", default="6", dest="hours", help="Number of hours since last checked in") return parser
def parse_command_line(): parser = optparse.OptionParser() parser.add_option("-v", "--verbose",action="store_true", dest="verbose", default=False,help="prints debug output and additional detail.") parser.add_option("-d", "--debug",action="store_true", dest="debug", default=False,help="run in debug mode and not service context.") parser.add_option("-b", "--bash",action="store_true", dest="schedule", default=False,help="create schedule file for bash shell based command / control.") parser.add_option("-m","--mask",dest="el_mask",type=float,default=0.0,help="mask all passes below the provided elevation.") parser.add_option("-c", "--config",dest="config",default='config/beacons.ini',help="Use configuration file <config>.") parser.add_option("-f", "--foreground",action="store_true",dest="foreground",help="Execute schedule in foreground.") parser.add_option("-s", "--starttime",dest="starttime",help="Start time in ISO8601 format, e.g. 2016-01-01T15:24:00Z") parser.add_option("-e", "--endtime",dest="endtime",help="End time in ISO8601 format, e.g. 2016-01-01T16:24:00Z") parser.add_option("-i", "--interval",dest="interval",type=float,default=10.0,help="Sampling interval for ephemeris predictions, default is 10 seconds.") parser.add_option("-r", "--radio",dest="site",default='config/site.ini',help="Radio site configuration file.") (options, args) = parser.parse_args() return (options, args)
def _get_opt_parser(self): parser = CustomOptionParser() parser.add_option("-l", "--lieu", type="string", dest="location", default="paris") parser.add_option("-q", "--quality", type="string", dest="quality") parser.add_option("-v", "--version", type="string", dest="version") parser.add_option("-d", "--day", type="string", dest="day", default="today") parser.add_option("-c", "--cine", type="int", dest="cine") parser.add_option("-p", "--page", type="int", dest="page", default=1) parser.add_option("--force", action="store_true", dest="force", default=False) return parser