当前位置: 首页>>代码示例>>Python>>正文


Python options.set_from_cmdline函数代码示例

本文整理汇总了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
开发者ID:Xodarap,项目名称:Eipi,代码行数:47,代码来源:sb_upload.py

示例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
开发者ID:ems316,项目名称:Active-Machine-Unlearning,代码行数:31,代码来源:sb_mboxtrain.py


注:本文中的spambayes.Options.options.set_from_cmdline函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。