當前位置: 首頁>>代碼示例>>Python>>正文


Python cmdoptions.index_url方法代碼示例

本文整理匯總了Python中pip._internal.cli.cmdoptions.index_url方法的典型用法代碼示例。如果您正苦於以下問題:Python cmdoptions.index_url方法的具體用法?Python cmdoptions.index_url怎麽用?Python cmdoptions.index_url使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pip._internal.cli.cmdoptions的用法示例。


在下文中一共展示了cmdoptions.index_url方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_line_parser

# 需要導入模塊: from pip._internal.cli import cmdoptions [as 別名]
# 或者: from pip._internal.cli.cmdoptions import index_url [as 別名]
def get_line_parser(finder):
    # type: (Optional[PackageFinder]) -> LineParser
    def parse_line(line):
        # type: (Text) -> Tuple[str, Values]
        # Build new parser for each line since it accumulates appendable
        # options.
        parser = build_parser()
        defaults = parser.get_default_values()
        defaults.index_url = None
        if finder:
            defaults.format_control = finder.format_control

        args_str, options_str = break_args_options(line)
        # Prior to 2.7.3, shlex cannot deal with unicode entries
        if sys.version_info < (2, 7, 3):
            # https://github.com/python/mypy/issues/1174
            options_str = options_str.encode('utf8')  # type: ignore

        # https://github.com/python/mypy/issues/1174
        opts, _ = parser.parse_args(
            shlex.split(options_str), defaults)  # type: ignore

        return args_str, opts

    return parse_line 
開發者ID:pantsbuild,項目名稱:pex,代碼行數:27,代碼來源:req_file.py

示例2: handle_option_line

# 需要導入模塊: from pip._internal.cli import cmdoptions [as 別名]
# 或者: from pip._internal.cli.cmdoptions import index_url [as 別名]
def handle_option_line(
    opts,  # type: Values
    filename,  # type: str
    lineno,  # type: int
    finder=None,  # type: Optional[PackageFinder]
    options=None,  # type: Optional[optparse.Values]
    session=None,  # type: Optional[PipSession]
):
    # type:  (...) -> None

    # percolate hash-checking option upward
    if opts.require_hashes:
        options.require_hashes = opts.require_hashes

    # set finder options
    elif finder:
        find_links = finder.find_links
        index_urls = finder.index_urls
        if opts.index_url:
            index_urls = [opts.index_url]
        if opts.no_index is True:
            index_urls = []
        if opts.extra_index_urls:
            index_urls.extend(opts.extra_index_urls)
        if opts.find_links:
            # FIXME: it would be nice to keep track of the source
            # of the find_links: support a find-links local path
            # relative to a requirements file.
            value = opts.find_links[0]
            req_dir = os.path.dirname(os.path.abspath(filename))
            relative_to_reqs_file = os.path.join(req_dir, value)
            if os.path.exists(relative_to_reqs_file):
                value = relative_to_reqs_file
            find_links.append(value)

        search_scope = SearchScope(
            find_links=find_links,
            index_urls=index_urls,
        )
        finder.search_scope = search_scope

        if opts.pre:
            finder.set_allow_all_prereleases()

        if session:
            for host in opts.trusted_hosts or []:
                source = 'line {} of {}'.format(lineno, filename)
                session.add_trusted_host(host, source=source) 
開發者ID:ali5h,項目名稱:rules_pip,代碼行數:50,代碼來源:req_file.py


注:本文中的pip._internal.cli.cmdoptions.index_url方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。