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


Python cmdoptions.no_index方法代碼示例

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


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

示例1: handle_option_line

# 需要導入模塊: from pip._internal.cli import cmdoptions [as 別名]
# 或者: from pip._internal.cli.cmdoptions import no_index [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.no_index方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。