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


Python pkg_resources.parse_requirements方法代碼示例

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


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

示例1: deduce_helpful_msg

# 需要導入模塊: from pip._vendor import pkg_resources [as 別名]
# 或者: from pip._vendor.pkg_resources import parse_requirements [as 別名]
def deduce_helpful_msg(req):
    """Returns helpful msg in case requirements file does not exist,
    or cannot be parsed.

    :params req: Requirements file path
    """
    msg = ""
    if os.path.exists(req):
        msg = " It does exist."
        # Try to parse and check if it is a requirements file.
        try:
            with open(req, 'r') as fp:
                # parse first line only
                next(parse_requirements(fp.read()))
                msg += " The argument you provided " + \
                    "(%s) appears to be a" % (req) + \
                    " requirements file. If that is the" + \
                    " case, use the '-r' flag to install" + \
                    " the packages specified within it."
        except RequirementParseError:
            logger.debug("Cannot parse '%s' as requirements \
            file" % (req), exc_info=1)
    else:
        msg += " File '%s' does not exist." % (req)
    return msg 
開發者ID:HaoZhang95,項目名稱:Python24,代碼行數:27,代碼來源:req_install.py

示例2: deduce_helpful_msg

# 需要導入模塊: from pip._vendor import pkg_resources [as 別名]
# 或者: from pip._vendor.pkg_resources import parse_requirements [as 別名]
def deduce_helpful_msg(req):
    # type: (str) -> str
    """Returns helpful msg in case requirements file does not exist,
    or cannot be parsed.

    :params req: Requirements file path
    """
    msg = ""
    if os.path.exists(req):
        msg = " It does exist."
        # Try to parse and check if it is a requirements file.
        try:
            with open(req, 'r') as fp:
                # parse first line only
                next(parse_requirements(fp.read()))
                msg += " The argument you provided " + \
                    "(%s) appears to be a" % (req) + \
                    " requirements file. If that is the" + \
                    " case, use the '-r' flag to install" + \
                    " the packages specified within it."
        except RequirementParseError:
            logger.debug("Cannot parse '%s' as requirements \
            file" % (req), exc_info=True)
    else:
        msg += " File '%s' does not exist." % (req)
    return msg


# ---- The actual constructors follow ---- 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:31,代碼來源:constructors.py

示例3: deduce_helpful_msg

# 需要導入模塊: from pip._vendor import pkg_resources [as 別名]
# 或者: from pip._vendor.pkg_resources import parse_requirements [as 別名]
def deduce_helpful_msg(req):
    # type: (str) -> str
    """Returns helpful msg in case requirements file does not exist,
    or cannot be parsed.

    :params req: Requirements file path
    """
    msg = ""
    if os.path.exists(req):
        msg = " It does exist."
        # Try to parse and check if it is a requirements file.
        try:
            with open(req, 'r') as fp:
                # parse first line only
                next(parse_requirements(fp.read()))
                msg += " The argument you provided " + \
                    "(%s) appears to be a" % (req) + \
                    " requirements file. If that is the" + \
                    " case, use the '-r' flag to install" + \
                    " the packages specified within it."
        except RequirementParseError:
            logger.debug("Cannot parse '%s' as requirements \
            file" % (req), exc_info=True)
    else:
        msg += " File '%s' does not exist." % (req)
    return msg 
開發者ID:pantsbuild,項目名稱:pex,代碼行數:28,代碼來源:constructors.py

示例4: deduce_helpful_msg

# 需要導入模塊: from pip._vendor import pkg_resources [as 別名]
# 或者: from pip._vendor.pkg_resources import parse_requirements [as 別名]
def deduce_helpful_msg(req):
    """Returns helpful msg in case requirements file does not exist,
    or cannot be parsed.

    :params req: Requirements file path
    """
    msg = ""
    if os.path.exists(req):
        msg = " It does exist."
        # Try to parse and check if it is a requirements file.
        try:
            with open(req, 'r') as fp:
                # parse first line only
                next(parse_requirements(fp.read()))
                msg += " The argument you provided " + \
                    "(%s) appears to be a" % (req) + \
                    " requirements file. If that is the" + \
                    " case, use the '-r' flag to install" + \
                    " the packages specified within it."
        except RequirementParseError:
            logger.debug("Cannot parse '%s' as requirements \
            file" % (req), exc_info=1)
    else:
        msg += " File '%s' does not exist." % (req)
    return msg


# ---- The actual constructors follow ---- 
開發者ID:luckystarufo,項目名稱:pySINDy,代碼行數:30,代碼來源:constructors.py

示例5: deduce_helpful_msg

# 需要導入模塊: from pip._vendor import pkg_resources [as 別名]
# 或者: from pip._vendor.pkg_resources import parse_requirements [as 別名]
def deduce_helpful_msg(req):
    # type: (str) -> str
    """Returns helpful msg in case requirements file does not exist,
    or cannot be parsed.

    :params req: Requirements file path
    """
    msg = ""
    if os.path.exists(req):
        msg = " It does exist."
        # Try to parse and check if it is a requirements file.
        try:
            with open(req, 'r') as fp:
                # parse first line only
                next(parse_requirements(fp.read()))
                msg += (
                    "The argument you provided "
                    "({}) appears to be a"
                    " requirements file. If that is the"
                    " case, use the '-r' flag to install"
                    " the packages specified within it."
                ).format(req)
        except RequirementParseError:
            logger.debug("Cannot parse '{}' as requirements \
            file".format(req), exc_info=True)
    else:
        msg += " File '{}' does not exist.".format(req)
    return msg 
開發者ID:ali5h,項目名稱:rules_pip,代碼行數:30,代碼來源:constructors.py


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