Python optparse 模块,make_option() 实例源码

我们从Python开源项目中,提取了以下34个代码示例,用于说明如何使用optparse.make_option()

项目:oc-pyang    作者:openconfig    | 项目源码 | 文件源码
def add_opts(self, optparser):
        optlist = [
            optparse.make_option("--oc-jstree-no-path",
                                 dest="jstree_no_path",
                                 action="store_true",
                                 help="""Do not include paths to make
                                       page less wide"""),
            optparse.make_option("--oc-jstree-strip",
                              dest="strip_namespace",
                              action="store_true",
                              help="""Strip namespace prefixes from
                                path components"""),
            ]

        g = optparser.add_option_group("OpenConfig JSTree output specific options")
        g.add_options(optlist)
项目:pyang-json-schema-plugin    作者:cmoberg    | 项目源码 | 文件源码
def add_opts(self, optparser):
        optlist = [
            optparse.make_option('--json-schema-debug',
                                 dest='schema_debug',
                                 action="store_true",
                                 help='JSON Schema debug'),
            optparse.make_option('--json-schema-path',
                                 dest='schema_path',
                                 help='JSON Schema path'),
            optparse.make_option('--json-schema-title',
                                 dest='schema_title',
                                 help='JSON Schema title'),
            ]

        group = optparser.add_option_group("JSON Schema-specific options")
        group.add_options(optlist)
项目:pyangext    作者:abravalheri    | 项目源码 | 文件源码
def dummy_plugin_content():
    """Dummy pyang content that dumps the contents of a parameter"""
    return dedent("""\
        import optparse
        from pyang import plugin

        def pyang_plugin_init():
            plugin.register_plugin(FakeFixturePlugin())

        class FakeFixturePlugin(plugin.PyangPlugin):
            def add_opts(self, optparser):
                g = optparser.add_option_group("FakeFixture Plugin Options")
                g.add_options([
                    optparse.make_option(
                        "--fake-fixture-option", default="Hello World!")
                ])

            def add_output_format(self, fmts):
                    self.multiple_modules = True
                    fmts['fake-fixture'] = self

            def emit(self, ctx, modules, fd):
                fd.write(ctx.opts.fake_fixture_option)""")
项目:python-zulip-api    作者:zulip    | 项目源码 | 文件源码
def __init__(self):
        P4Sync.__init__(self)
        self.description = "Creates a new git repository and imports from Perforce into it"
        self.usage = "usage: %prog [options] //depot/path[@revRange]"
        self.options += [
            optparse.make_option("--destination", dest="cloneDestination",
                                 action='store', default=None,
                                 help="where to leave result of the clone"),
            optparse.make_option("-/", dest="cloneExclude",
                                 action="append", type="string",
                                 help="exclude depot path"),
            optparse.make_option("--bare", dest="cloneBare",
                                 action="store_true", default=False),
        ]
        self.cloneDestination = None
        self.needsGit = False
        self.cloneBare = False

    # This is required for the "append" cloneExclude action
项目:oc-pyang    作者:openconfig    | 项目源码 | 文件源码
def add_opts(self, optparser):
    optlist = [
        optparse.make_option("--openconfig",
                             dest="openconfig",
                             action="store_true",
                             help="""Validate the module(s) according to
                             OpenConfig conventions"""),
        optparse.make_option("--oc-only",
                             dest="openconfig_only",
                             action="store_true",
                             help="""Do not include standard lint (RFC 6087)
                             checking"""),
        ]
    g = optparser.add_option_group("OpenConfig specific options")
    g.add_options(optlist)
项目:oc-pyang    作者:openconfig    | 项目源码 | 文件源码
def add_opts(self, optparser):
    optlist = [
        optparse.make_option("--meta-only",
                              dest="meta_only",
                              action="store_true",
                              help="""Only produce documentation based on the
                              module metadata"""),
        optparse.make_option("--doc-format",
                              dest="doc_format",
                              action="store",
                              type="string",
                              default="markdown",
                              help="""Doc output format: markdown, html"""),
        optparse.make_option("--strip-ns",
                              dest="strip_namespace",
                              action="store_true",
                              help="""Strip namespace prefixes from
                                displayed paths"""),
        optparse.make_option("--no-structure",
                              dest="no_structure",
                              action="store_true",
                              help="""Do not generate docs for structure-only nodes (e.g., containers)"""),
        optparse.make_option("--doc-title",
                              dest="doc_title",
                              action="store",
                              type="string",
                              help="""Set the title of the output documentation page"""),
                ]
    g = optparser.add_option_group("docs output specific options")
    g.add_options(optlist)
项目:midip-sslyze    作者:soukupa5    | 项目源码 | 文件源码
def add_option(self, option, help, dest=None):
        """Options are settings specific to one single plugin; they will passed to process_task() in the options_dict.
        """
        # If dest is something, store it, otherwise just use store_true
        action="store_true"
        if dest is not None:
            action="store"

        self._options.append(make_option('--{}'.format(option), action=action, help=help, dest=dest))
项目:midip-sslyze    作者:soukupa5    | 项目源码 | 文件源码
def add_command(self, command, help, aggressive=False):
        """Commands are actions/scans the plugin implements, with PluginXXX.process_task().

        Setting aggressive to True is a warning that the command will open many simultaneous connections to the server
        and should therefore not be run concurrently with other `aggressive` commands against a given server.
        """

        self._commands.append(make_option('--{}'.format(command), action='store_true', help=help))
        self._commands_as_text.append((command, aggressive))
项目:midip-sslyze    作者:soukupa5    | 项目源码 | 文件源码
def _make_option(command, help, dest):
        # If dest is something, store it, otherwise just use store_true
        action="store_true"
        if dest is not None:
            action="store"

        return make_option('--' + command, action=action, help=help, dest=dest)
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def make_options():
    opts = [
        make_option('--adminmedia', dest='admin_media_path', default='',
        help='Specifies the directory from which to serve admin media.')
    ]

    g_settings = make_settings(ignore=("version"))
    keys = g_settings.keys()
    for k in keys:
        if k in ('pythonpath', 'django_settings',):
            continue

        setting = g_settings[k]
        if not setting.cli:
            continue

        args = tuple(setting.cli)

        kwargs = {
            "dest": setting.name,
            "metavar": setting.meta or None,
            "action": setting.action or "store",
            "type": setting.type or "string",
            "default": None,
            "help": "%s [%s]" % (setting.short, setting.default)
        }
        if kwargs["action"] != "store":
            kwargs.pop("type")

        opts.append(make_option(*args, **kwargs))

    return tuple(opts)
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def make_options():
    opts = [
        make_option('--adminmedia', dest='admin_media_path', default='',
        help='Specifies the directory from which to serve admin media.')
    ]

    g_settings = make_settings(ignore=("version"))
    keys = g_settings.keys()
    for k in keys:
        if k in ('pythonpath', 'django_settings',):
            continue

        setting = g_settings[k]
        if not setting.cli:
            continue

        args = tuple(setting.cli)

        kwargs = {
            "dest": setting.name,
            "metavar": setting.meta or None,
            "action": setting.action or "store",
            "type": setting.type or "string",
            "default": None,
            "help": "%s [%s]" % (setting.short, setting.default)
        }
        if kwargs["action"] != "store":
            kwargs.pop("type")

        opts.append(make_option(*args, **kwargs))

    return tuple(opts)
项目:Price-Comparator    作者:Thejas-1    | 项目源码 | 文件源码
def make_options():
    opts = [
        make_option('--adminmedia', dest='admin_media_path', default='',
        help='Specifies the directory from which to serve admin media.')
    ]

    g_settings = make_settings(ignore=("version"))
    keys = g_settings.keys()
    for k in keys:
        if k in ('pythonpath', 'django_settings',):
            continue

        setting = g_settings[k]
        if not setting.cli:
            continue

        args = tuple(setting.cli)

        kwargs = {
            "dest": setting.name,
            "metavar": setting.meta or None,
            "action": setting.action or "store",
            "type": setting.type or "string",
            "default": None,
            "help": "%s [%s]" % (setting.short, setting.default)
        }
        if kwargs["action"] != "store":
            kwargs.pop("type")

        opts.append(make_option(*args, **kwargs))

    return tuple(opts)
项目:tabmaster    作者:NicolasMinghetti    | 项目源码 | 文件源码
def make_options():
    opts = [
        make_option('--adminmedia', dest='admin_media_path', default='',
        help='Specifies the directory from which to serve admin media.')
    ]

    g_settings = make_settings(ignore=("version"))
    keys = g_settings.keys()
    for k in keys:
        if k in ('pythonpath', 'django_settings',):
            continue

        setting = g_settings[k]
        if not setting.cli:
            continue

        args = tuple(setting.cli)

        kwargs = {
            "dest": setting.name,
            "metavar": setting.meta or None,
            "action": setting.action or "store",
            "type": setting.type or "string",
            "default": None,
            "help": "%s [%s]" % (setting.short, setting.default)
        }
        if kwargs["action"] != "store":
            kwargs.pop("type")

        opts.append(make_option(*args, **kwargs))

    return tuple(opts)
项目:infiblog    作者:RajuKoushik    | 项目源码 | 文件源码
def make_options():
    opts = [
        make_option('--adminmedia', dest='admin_media_path', default='',
        help='Specifies the directory from which to serve admin media.')
    ]

    g_settings = make_settings(ignore=("version"))
    keys = g_settings.keys()
    for k in keys:
        if k in ('pythonpath', 'django_settings',):
            continue

        setting = g_settings[k]
        if not setting.cli:
            continue

        args = tuple(setting.cli)

        kwargs = {
            "dest": setting.name,
            "metavar": setting.meta or None,
            "action": setting.action or "store",
            "type": setting.type or "string",
            "default": None,
            "help": "%s [%s]" % (setting.short, setting.default)
        }
        if kwargs["action"] != "store":
            kwargs.pop("type")

        opts.append(make_option(*args, **kwargs))

    return tuple(opts)
项目:stgit    作者:ctmarinas    | 项目源码 | 文件源码
def get_option(self):
        kwargs = dict(self.kwargs)
        kwargs['help'] = kwargs['short']
        for k in ['short', 'long', 'args']:
            kwargs.pop(k, None)
        return optparse.make_option(*self.pargs, **kwargs)
项目:metrics    作者:Jeremy-Friedman    | 项目源码 | 文件源码
def make_options():
    opts = [
        make_option('--adminmedia', dest='admin_media_path', default='',
        help='Specifies the directory from which to serve admin media.')
    ]

    g_settings = make_settings(ignore=("version"))
    keys = g_settings.keys()
    for k in keys:
        if k in ('pythonpath', 'django_settings',):
            continue

        setting = g_settings[k]
        if not setting.cli:
            continue

        args = tuple(setting.cli)

        kwargs = {
            "dest": setting.name,
            "metavar": setting.meta or None,
            "action": setting.action or "store",
            "type": setting.type or "string",
            "default": None,
            "help": "%s [%s]" % (setting.short, setting.default)
        }
        if kwargs["action"] != "store":
            kwargs.pop("type")

        opts.append(make_option(*args, **kwargs))

    return tuple(opts)
项目:metrics    作者:Jeremy-Friedman    | 项目源码 | 文件源码
def make_options():
    opts = [
        make_option('--adminmedia', dest='admin_media_path', default='',
        help='Specifies the directory from which to serve admin media.')
    ]

    g_settings = make_settings(ignore=("version"))
    keys = g_settings.keys()
    for k in keys:
        if k in ('pythonpath', 'django_settings',):
            continue

        setting = g_settings[k]
        if not setting.cli:
            continue

        args = tuple(setting.cli)

        kwargs = {
            "dest": setting.name,
            "metavar": setting.meta or None,
            "action": setting.action or "store",
            "type": setting.type or "string",
            "default": None,
            "help": "%s [%s]" % (setting.short, setting.default)
        }
        if kwargs["action"] != "store":
            kwargs.pop("type")

        opts.append(make_option(*args, **kwargs))

    return tuple(opts)
项目:logo-gen    作者:jellene4eva    | 项目源码 | 文件源码
def make_options():
    opts = [
        make_option('--adminmedia', dest='admin_media_path', default='',
        help='Specifies the directory from which to serve admin media.')
    ]

    g_settings = make_settings(ignore=("version"))
    keys = g_settings.keys()
    for k in keys:
        if k in ('pythonpath', 'django_settings',):
            continue

        setting = g_settings[k]
        if not setting.cli:
            continue

        args = tuple(setting.cli)

        kwargs = {
            "dest": setting.name,
            "metavar": setting.meta or None,
            "action": setting.action or "store",
            "type": setting.type or "string",
            "default": None,
            "help": "%s [%s]" % (setting.short, setting.default)
        }
        if kwargs["action"] != "store":
            kwargs.pop("type")

        opts.append(make_option(*args, **kwargs))

    return tuple(opts)
项目:liberator    作者:libscie    | 项目源码 | 文件源码
def make_options():
    opts = [
        make_option('--adminmedia', dest='admin_media_path', default='',
        help='Specifies the directory from which to serve admin media.')
    ]

    g_settings = make_settings(ignore=("version"))
    keys = g_settings.keys()
    for k in keys:
        if k in ('pythonpath', 'django_settings',):
            continue

        setting = g_settings[k]
        if not setting.cli:
            continue

        args = tuple(setting.cli)

        kwargs = {
            "dest": setting.name,
            "metavar": setting.meta or None,
            "action": setting.action or "store",
            "type": setting.type or "string",
            "default": None,
            "help": "%s [%s]" % (setting.short, setting.default)
        }
        if kwargs["action"] != "store":
            kwargs.pop("type")

        opts.append(make_option(*args, **kwargs))

    return tuple(opts)
项目:compatify    作者:hatooku    | 项目源码 | 文件源码
def make_options():
    opts = [
        make_option('--adminmedia', dest='admin_media_path', default='',
        help='Specifies the directory from which to serve admin media.')
    ]

    g_settings = make_settings(ignore=("version"))
    keys = g_settings.keys()
    for k in keys:
        if k in ('pythonpath', 'django_settings',):
            continue

        setting = g_settings[k]
        if not setting.cli:
            continue

        args = tuple(setting.cli)

        kwargs = {
            "dest": setting.name,
            "metavar": setting.meta or None,
            "action": setting.action or "store",
            "type": setting.type or "string",
            "default": None,
            "help": "%s [%s]" % (setting.short, setting.default)
        }
        if kwargs["action"] != "store":
            kwargs.pop("type")

        opts.append(make_option(*args, **kwargs))

    return tuple(opts)
项目:djanoDoc    作者:JustinChavez    | 项目源码 | 文件源码
def make_options():
    opts = [
        make_option('--adminmedia', dest='admin_media_path', default='',
        help='Specifies the directory from which to serve admin media.')
    ]

    g_settings = make_settings(ignore=("version"))
    keys = g_settings.keys()
    for k in keys:
        if k in ('pythonpath', 'django_settings',):
            continue

        setting = g_settings[k]
        if not setting.cli:
            continue

        args = tuple(setting.cli)

        kwargs = {
            "dest": setting.name,
            "metavar": setting.meta or None,
            "action": setting.action or "store",
            "type": setting.type or "string",
            "default": None,
            "help": "%s [%s]" % (setting.short, setting.default)
        }
        if kwargs["action"] != "store":
            kwargs.pop("type")

        opts.append(make_option(*args, **kwargs))

    return tuple(opts)
项目:Data-visualization    作者:insta-code1    | 项目源码 | 文件源码
def make_options():
    opts = [
        make_option('--adminmedia', dest='admin_media_path', default='',
        help='Specifies the directory from which to serve admin media.')
    ]

    g_settings = make_settings(ignore=("version"))
    keys = g_settings.keys()
    for k in keys:
        if k in ('pythonpath', 'django_settings',):
            continue

        setting = g_settings[k]
        if not setting.cli:
            continue

        args = tuple(setting.cli)

        kwargs = {
            "dest": setting.name,
            "metavar": setting.meta or None,
            "action": setting.action or "store",
            "type": setting.type or "string",
            "default": None,
            "help": "%s [%s]" % (setting.short, setting.default)
        }
        if kwargs["action"] != "store":
            kwargs.pop("type")

        opts.append(make_option(*args, **kwargs))

    return tuple(opts)
项目:tissuelab    作者:VirtualPlants    | 项目源码 | 文件源码
def layer_option(option, opt, value, parser):
    """
    Callback for `make_option` for the `ogrinspect` `layer_key`
    keyword option which may be an integer or a string.
    """
    try:
        dest = int(value)
    except ValueError:
        dest = value
    setattr(parser.values, option.dest, dest)
项目:tissuelab    作者:VirtualPlants    | 项目源码 | 文件源码
def list_option(option, opt, value, parser):
    """
    Callback for `make_option` for `ogrinspect` keywords that require
    a string list.  If the string is 'True'/'true' then the option
    value will be a boolean instead.
    """
    if value.lower() == 'true':
        dest = True
    else:
        dest = [s for s in value.split(',')]
    setattr(parser.values, option.dest, dest)
项目:django-next-train    作者:bitpixdigital    | 项目源码 | 文件源码
def make_options():
    opts = [
        make_option('--adminmedia', dest='admin_media_path', default='',
        help='Specifies the directory from which to serve admin media.')
    ]

    g_settings = make_settings(ignore=("version"))
    keys = g_settings.keys()
    for k in keys:
        if k in ('pythonpath', 'django_settings',):
            continue

        setting = g_settings[k]
        if not setting.cli:
            continue

        args = tuple(setting.cli)

        kwargs = {
            "dest": setting.name,
            "metavar": setting.meta or None,
            "action": setting.action or "store",
            "type": setting.type or "string",
            "default": None,
            "help": "%s [%s]" % (setting.short, setting.default)
        }
        if kwargs["action"] != "store":
            kwargs.pop("type")

        opts.append(make_option(*args, **kwargs))

    return tuple(opts)
项目:Lixiang_zhaoxin    作者:hejaxian    | 项目源码 | 文件源码
def make_options():
    opts = [
        make_option('--adminmedia', dest='admin_media_path', default='',
        help='Specifies the directory from which to serve admin media.')
    ]

    g_settings = make_settings(ignore=("version"))
    keys = g_settings.keys()
    for k in keys:
        if k in ('pythonpath', 'django_settings',):
            continue

        setting = g_settings[k]
        if not setting.cli:
            continue

        args = tuple(setting.cli)

        kwargs = {
            "dest": setting.name,
            "metavar": setting.meta or None,
            "action": setting.action or "store",
            "type": setting.type or "string",
            "default": None,
            "help": "%s [%s]" % (setting.short, setting.default)
        }
        if kwargs["action"] != "store":
            kwargs.pop("type")

        opts.append(make_option(*args, **kwargs))

    return tuple(opts)
项目:python-zulip-api    作者:zulip    | 项目源码 | 文件源码
def __init__(self):
        Command.__init__(self)
        self.options = [
            optparse.make_option("--local", dest="rollbackLocalBranches", action="store_true")
        ]
        self.description = "A tool to debug the multi-branch import. Don't use :)"
        self.rollbackLocalBranches = False
项目:python-zulip-api    作者:zulip    | 项目源码 | 文件源码
def __init__(self):
        Command.__init__(self)
        P4UserMap.__init__(self)
        self.options = [
                optparse.make_option("--origin", dest="origin"),
                optparse.make_option("-M", dest="detectRenames", action="store_true"),
                # preserve the user, requires relevant p4 permissions
                optparse.make_option("--preserve-user", dest="preserveUser", action="store_true"),
                optparse.make_option("--export-labels", dest="exportLabels", action="store_true"),
                optparse.make_option("--dry-run", "-n", dest="dry_run", action="store_true"),
                optparse.make_option("--prepare-p4-only", dest="prepare_p4_only", action="store_true"),
                optparse.make_option("--conflict", dest="conflict_behavior",
                                     choices=self.conflict_behavior_choices),
                optparse.make_option("--branch", dest="branch"),
        ]
        self.description = "Submit changes from git to the perforce depot."
        self.usage += " [name of git branch to submit into perforce depot]"
        self.origin = ""
        self.detectRenames = False
        self.preserveUser = gitConfigBool("git-p4.preserveUser")
        self.dry_run = False
        self.prepare_p4_only = False
        self.conflict_behavior = None
        self.isWindows = (platform.system() == "Windows")
        self.exportLabels = False
        self.p4HasMoveCommand = p4_has_move_command()
        self.branch = None
项目:python-zulip-api    作者:zulip    | 项目源码 | 文件源码
def __init__(self):
        Command.__init__(self)
        self.options = [
                optparse.make_option("--import-labels", dest="importLabels", action="store_true"),
        ]
        self.importLabels = False
        self.description = ("Fetches the latest revision from perforce and "
                            + "rebases the current work (branch) against it")
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
def make_options():
    opts = [
        make_option('--adminmedia', dest='admin_media_path', default='',
        help='Specifies the directory from which to serve admin media.')
    ]

    g_settings = make_settings(ignore=("version"))
    keys = g_settings.keys()
    for k in keys:
        if k in ('pythonpath', 'django_settings',):
            continue

        setting = g_settings[k]
        if not setting.cli:
            continue

        args = tuple(setting.cli)

        kwargs = {
            "dest": setting.name,
            "metavar": setting.meta or None,
            "action": setting.action or "store",
            "type": setting.type or "string",
            "default": None,
            "help": "%s [%s]" % (setting.short, setting.default)
        }
        if kwargs["action"] != "store":
            kwargs.pop("type")

        opts.append(make_option(*args, **kwargs))

    return tuple(opts)
项目:oc-pyang    作者:openconfig    | 项目源码 | 文件源码
def add_opts(self, optparser):
    optlist = [
        optparse.make_option("--strip",
                              dest="strip_namespace",
                              action="store_true",
                              help="""Strip namespace prefixes from
                                path components"""),
        optparse.make_option("--opstate",
                              dest="opstate_paths",
                              action="store_true",
                              help="""Print list of operational state paths,
                              i.e., containing config:false leaves"""),
        optparse.make_option("--root",
                              dest="root_only",
                              action="store_true",
                              help="""List only root nodes (depth=1)"""),
        optparse.make_option("--no-errors",
                              dest="ignore_errors",
                              action="store_true",
                              help="""Try to ignore compilation errors"""),
        optparse.make_option("--include-keyword",
                              dest="include_keyword",
                              action="store_true",
                              help="""Display the type of node for each path,
                              e.g., leaf, container, etc."""),
        optparse.make_option("--print-depth",
                              dest="print_depth",
                              action="store_true",
                              help="""Display the tree depth of each path (root
                                is at depth [1]"""),
        optparse.make_option("--plain",
                              dest="print_plain",
                              action="store_true",
                              help="""Print only paths (useful with relocate
                                plugin"""),
        optparse.make_option("--for-relocate",
                              dest="relocate_output",
                              action="store_true",
                              help="""Generate paths output for use with relocate
                              plugin"""),
                ]
    g = optparser.add_option_group("paths output specific options")
    g.add_options(optlist)
项目:PocHunter    作者:DavexPro    | 项目源码 | 文件源码
def options(option_list, arg_desc="arg"):
    '''Used as a decorator and passed a list of optparse-style options,
       alters a cmd2 method to populate its ``opts`` argument from its
       raw text argument.

       Example: transform
       def do_something(self, arg):

       into
       @options([make_option('-q', '--quick', action="store_true",
                 help="Makes things fast")],
                 "source dest")
       def do_something(self, arg, opts):
           if opts.quick:
               self.fast_button = True
       '''
    if not isinstance(option_list, list):
        option_list = [option_list]
    for opt in option_list:
        options_defined.append(pyparsing.Literal(opt.get_opt_string()))
    def option_setup(func):
        optionParser = OptionParser()
        for opt in option_list:
            optionParser.add_option(opt)
        optionParser.set_usage("%s [options] %s" % (func.__name__[3:], arg_desc))
        optionParser._func = func
        def new_func(instance, arg):
            try:
                opts, newArgList = optionParser.parse_args(arg.split())
                # Must find the remaining args in the original argument list, but 
                # mustn't include the command itself
                #if hasattr(arg, 'parsed') and newArgList[0] == arg.parsed.command:
                #    newArgList = newArgList[1:]
                newArgs = remaining_args(arg, newArgList)
                if isinstance(arg, ParsedString):
                    arg = arg.with_args_replaced(newArgs)
                else:
                    arg = newArgs
            except optparse.OptParseError as e:
                print (e)
                optionParser.print_help()
                return
            if hasattr(opts, '_exit'):
                return None
            result = func(instance, arg, opts)                            
            return result        
        new_func.__doc__ = '%s\n%s' % (func.__doc__, optionParser.format_help())
        return new_func
    return option_setup
项目:python-zulip-api    作者:zulip    | 项目源码 | 文件源码
def __init__(self):
        Command.__init__(self)
        P4UserMap.__init__(self)
        self.options = [
                optparse.make_option("--branch", dest="branch"),
                optparse.make_option("--detect-branches", dest="detectBranches", action="store_true"),
                optparse.make_option("--changesfile", dest="changesFile"),
                optparse.make_option("--silent", dest="silent", action="store_true"),
                optparse.make_option("--detect-labels", dest="detectLabels", action="store_true"),
                optparse.make_option("--import-labels", dest="importLabels", action="store_true"),
                optparse.make_option("--import-local", dest="importIntoRemotes", action="store_false",
                                     help="Import into refs/heads/ , not refs/remotes"),
                optparse.make_option("--max-changes", dest="maxChanges"),
                optparse.make_option("--keep-path", dest="keepRepoPath", action='store_true',
                                     help="Keep entire BRANCH/DIR/SUBDIR prefix during import"),
                optparse.make_option("--use-client-spec", dest="useClientSpec", action='store_true',
                                     help="Only sync files that are included in the Perforce Client Spec")
        ]
        self.description = """Imports from Perforce into a git repository.\n
    example:
    //depot/my/project/ -- to import the current head
    //depot/my/project/@all -- to import everything
    //depot/my/project/@1,6 -- to import only from revision 1 to 6

    (a ... is not needed in the path p4 specification, it's added implicitly)"""

        self.usage += " //depot/path[@revRange]"
        self.silent = False
        self.createdBranches = set()
        self.committedChanges = set()
        self.branch = ""
        self.detectBranches = False
        self.detectLabels = False
        self.importLabels = False
        self.changesFile = ""
        self.syncWithOrigin = True
        self.importIntoRemotes = True
        self.maxChanges = ""
        self.keepRepoPath = False
        self.depotPaths = None
        self.p4BranchesInGit = []
        self.cloneExclude = []
        self.useClientSpec = False
        self.useClientSpec_from_options = False
        self.clientSpecDirs = None
        self.tempBranches = []
        self.tempBranchLocation = "git-p4-tmp"

        if gitConfig("git-p4.syncFromOrigin") == "false":
            self.syncWithOrigin = False

    # Force a checkpoint in fast-import and wait for it to finish
项目:OpenRAM    作者:mguthaus    | 项目源码 | 文件源码
def parse_args():
    """ Parse the optional arguments for OpenRAM """

    global OPTS

    option_list = {
        optparse.make_option("-b", "--backannotated", action="store_true", dest="run_pex",
                             help="Back annotate simulation"),
        optparse.make_option("-o", "--output", dest="output_name",
                             help="Base output file name(s) prefix", metavar="FILE"),
        optparse.make_option("-p", "--outpath", dest="output_path",
                             help="Output file(s) location"),
        optparse.make_option("-n", "--nocheck", action="store_false",
                             help="Disable inline LVS/DRC checks", dest="check_lvsdrc"),
        optparse.make_option("-q", "--quiet", action="store_false", dest="print_banner",
                             help="Don\'t display banner"),
        optparse.make_option("-v", "--verbose", action="count", dest="debug_level",
                             help="Increase the verbosity level"),
        optparse.make_option("-t", "--tech", dest="tech_name",
                             help="Technology name"),
        optparse.make_option("-s", "--spice", dest="spice_name",
                             help="Spice simulator executable name"),
        optparse.make_option("-r", "--remove_netlist_trimming", action="store_false", dest="trim_netlist",
                             help="Disable removal of noncritical memory cells during characterization"),
        optparse.make_option("-c", "--characterize", action="store_false", dest="analytical_delay",
                             help="Perform characterization to calculate delays (default is analytical models)")
        # -h --help is implicit.
    }

    parser = optparse.OptionParser(option_list=option_list,
                                   description="Compile and/or characterize an SRAM.",
                                   usage=USAGE,
                                   version="OpenRAM v" + VERSION)

    (options, args) = parser.parse_args(values=OPTS)

    # If we don't specify a tech, assume freepdk45.
    # This may be overridden when we read a config file though...
    if OPTS.tech_name == "":
        OPTS.tech_name = "freepdk45"

    return (options, args)