本文整理汇总了Python中spambayes.Options.options.set_from_cmdline函数的典型用法代码示例。如果您正苦于以下问题:Python set_from_cmdline函数的具体用法?Python set_from_cmdline怎么用?Python set_from_cmdline使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_from_cmdline函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main(argv):
null = False
server = "localhost"
port = options["html_ui", "port"]
prob = 1.0
try:
opts, args = getopt.getopt(argv, "hns:p:r:o:",
["help", "null", "server=", "port=",
"prob=", "option="])
except getopt.error:
usage(globals(), locals())
sys.exit(1)
for opt, arg in opts:
if opt in ("-h", "--help"):
usage(globals(), locals())
sys.exit(0)
elif opt in ("-n", "--null"):
null = True
elif opt in ("-s", "--server"):
server = arg
elif opt in ("-p", "--port"):
port = int(arg)
elif opt in ("-r", "--prob"):
n = float(arg)
if n < 0.0 or n > 1.0:
usage(globals(), locals())
sys.exit(1)
prob = n
elif opt in ('-o', '--option'):
options.set_from_cmdline(arg, sys.stderr)
if args:
usage(globals(), locals())
sys.exit(1)
data = sys.stdin.read()
if not null:
sys.stdout.write(data)
if random.random() < prob:
try:
post_multipart("%s:%d"%(server,port), "/upload", [],
[('file', 'message.dat', data)])
except:
# not an error if the server isn't responding
pass
示例2: usage
if opt == '-h':
usage(0)
elif opt == "-f":
force = True
elif opt == "-n":
trainnew = True
elif opt == "-q":
loud = False
elif opt == '-g':
good.append(arg)
elif opt == '-s':
spam.append(arg)
elif opt == "-r":
removetrained = True
elif opt == '-o':
options.set_from_cmdline(arg, sys.stderr)
pck, usedb = storage.database_type(opts)
if args:
usage(2, "Positional arguments not allowed")
if usedb == None:
# Use settings in configuration file.
usedb = options["Storage", "persistent_use_database"]
pck = get_pathname_option("Storage",
"persistent_storage_file")
h = hammie.open(pck, usedb, "c")
for g in good:
if loud:
print "Training ham (%s):" % g