本文整理汇总了Python中pip._vendor.pkg_resources.RequirementParseError方法的典型用法代码示例。如果您正苦于以下问题:Python pkg_resources.RequirementParseError方法的具体用法?Python pkg_resources.RequirementParseError怎么用?Python pkg_resources.RequirementParseError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pip._vendor.pkg_resources
的用法示例。
在下文中一共展示了pkg_resources.RequirementParseError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deduce_helpful_msg
# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import RequirementParseError [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
示例2: create_package_set_from_installed
# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import RequirementParseError [as 别名]
def create_package_set_from_installed(**kwargs):
# type: (**Any) -> Tuple[PackageSet, bool]
"""Converts a list of distributions into a PackageSet.
"""
# Default to using all packages installed on the system
if kwargs == {}:
kwargs = {"local_only": False, "skip": ()}
package_set = {}
problems = False
for dist in get_installed_distributions(**kwargs):
name = canonicalize_name(dist.project_name)
try:
package_set[name] = PackageDetails(dist.version, dist.requires())
except RequirementParseError as e:
# Don't crash on broken metadata
logging.warning("Error parsing requirements for %s: %s", name, e)
problems = True
return package_set, problems
示例3: create_package_set_from_installed
# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import RequirementParseError [as 别名]
def create_package_set_from_installed(**kwargs):
# type: (**Any) -> Tuple[PackageSet, bool]
"""Converts a list of distributions into a PackageSet.
"""
# Default to using all packages installed on the system
if kwargs == {}:
kwargs = {"local_only": False, "skip": ()}
package_set = {}
problems = False
for dist in get_installed_distributions(**kwargs):
name = canonicalize_name(dist.project_name)
try:
package_set[name] = PackageDetails(dist.version, dist.requires())
except RequirementParseError as e:
# Don't crash on broken metadata
logger.warning("Error parsing requirements for %s: %s", name, e)
problems = True
return package_set, problems
示例4: parse_requirement
# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import RequirementParseError [as 别名]
def parse_requirement(line: str, editable: bool = False) -> Requirement:
m = VCS_REQ.match(line)
if m is not None:
r = VcsRequirement.parse(line, m.groupdict())
else:
try:
r = NamedRequirement.parse(line) # type: Requirement
except RequirementParseError as e:
m = FILE_REQ.match(line)
if m is not None:
r = FileRequirement.parse(line, m.groupdict())
else:
raise RequirementError(str(e)) from None
else:
if r.url:
r = FileRequirement(name=r.name, url=r.url, extras=r.extras)
if editable:
if r.is_vcs or r.is_file_or_url and r.is_local_dir:
r.editable = True
else:
raise RequirementError(
"Editable requirement is only supported for VCS link"
" or local directory."
)
return r