当前位置: 首页>>代码示例>>Python>>正文


Python pyparsing.ParseException方法代码示例

本文整理汇总了Python中pip._vendor.pyparsing.ParseException方法的典型用法代码示例。如果您正苦于以下问题:Python pyparsing.ParseException方法的具体用法?Python pyparsing.ParseException怎么用?Python pyparsing.ParseException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pip._vendor.pyparsing的用法示例。


在下文中一共展示了pyparsing.ParseException方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from pip._vendor import pyparsing [as 别名]
# 或者: from pip._vendor.pyparsing import ParseException [as 别名]
def __init__(self, requirement_string):
        try:
            req = REQUIREMENT.parseString(requirement_string)
        except ParseException as e:
            raise InvalidRequirement(
                "Invalid requirement, parse error at \"{0!r}\"".format(
                    requirement_string[e.loc:e.loc + 8]))

        self.name = req.name
        if req.url:
            parsed_url = urlparse.urlparse(req.url)
            if not (parsed_url.scheme and parsed_url.netloc) or (
                    not parsed_url.scheme and not parsed_url.netloc):
                raise InvalidRequirement("Invalid URL given")
            self.url = req.url
        else:
            self.url = None
        self.extras = set(req.extras.asList() if req.extras else [])
        self.specifier = SpecifierSet(req.specifier)
        self.marker = req.marker if req.marker else None 
开发者ID:HaoZhang95,项目名称:Python24,代码行数:22,代码来源:requirements.py

示例2: __init__

# 需要导入模块: from pip._vendor import pyparsing [as 别名]
# 或者: from pip._vendor.pyparsing import ParseException [as 别名]
def __init__(self, requirement_string):
        try:
            req = REQUIREMENT.parseString(requirement_string)
        except ParseException as e:
            raise InvalidRequirement("Parse error at \"{0!r}\": {1}".format(
                requirement_string[e.loc:e.loc + 8], e.msg
            ))

        self.name = req.name
        if req.url:
            parsed_url = urlparse.urlparse(req.url)
            if not (parsed_url.scheme and parsed_url.netloc) or (
                    not parsed_url.scheme and not parsed_url.netloc):
                raise InvalidRequirement("Invalid URL: {0}".format(req.url))
            self.url = req.url
        else:
            self.url = None
        self.extras = set(req.extras.asList() if req.extras else [])
        self.specifier = SpecifierSet(req.specifier)
        self.marker = req.marker if req.marker else None 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:22,代码来源:requirements.py

示例3: __init__

# 需要导入模块: from pip._vendor import pyparsing [as 别名]
# 或者: from pip._vendor.pyparsing import ParseException [as 别名]
def __init__(self, marker):
        try:
            self._markers = _coerce_parse_result(MARKER.parseString(marker))
        except ParseException as e:
            err_str = "Invalid marker: {0!r}, parse error at {1!r}".format(
                marker, marker[e.loc:e.loc + 8])
            raise InvalidMarker(err_str) 
开发者ID:HaoZhang95,项目名称:Python24,代码行数:9,代码来源:markers.py

示例4: __init__

# 需要导入模块: from pip._vendor import pyparsing [as 别名]
# 或者: from pip._vendor.pyparsing import ParseException [as 别名]
def __init__(self, requirement_string):
        try:
            req = REQUIREMENT.parseString(requirement_string)
        except ParseException as e:
            raise InvalidRequirement(
                'Parse error at "{0!r}": {1}'.format(
                    requirement_string[e.loc : e.loc + 8], e.msg
                )
            )

        self.name = req.name
        if req.url:
            parsed_url = urlparse.urlparse(req.url)
            if parsed_url.scheme == "file":
                if urlparse.urlunparse(parsed_url) != req.url:
                    raise InvalidRequirement("Invalid URL given")
            elif not (parsed_url.scheme and parsed_url.netloc) or (
                not parsed_url.scheme and not parsed_url.netloc
            ):
                raise InvalidRequirement("Invalid URL: {0}".format(req.url))
            self.url = req.url
        else:
            self.url = None
        self.extras = set(req.extras.asList() if req.extras else [])
        self.specifier = SpecifierSet(req.specifier)
        self.marker = req.marker if req.marker else None 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:28,代码来源:requirements.py

示例5: __init__

# 需要导入模块: from pip._vendor import pyparsing [as 别名]
# 或者: from pip._vendor.pyparsing import ParseException [as 别名]
def __init__(self, marker):
        try:
            self._markers = _coerce_parse_result(MARKER.parseString(marker))
        except ParseException as e:
            err_str = "Invalid marker: {0!r}, parse error at {1!r}".format(
                marker, marker[e.loc : e.loc + 8]
            )
            raise InvalidMarker(err_str) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:10,代码来源:markers.py


注:本文中的pip._vendor.pyparsing.ParseException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。