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


Python pyparsing.ParseException方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: from setuptools.extern import pyparsing [as 別名]
# 或者: from setuptools.extern.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:ryfeus,項目名稱:lambda-packs,代碼行數:22,代碼來源:requirements.py

示例2: __init__

# 需要導入模塊: from setuptools.extern import pyparsing [as 別名]
# 或者: from setuptools.extern.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:ryfeus,項目名稱:lambda-packs,代碼行數:9,代碼來源:markers.py

示例3: __init__

# 需要導入模塊: from setuptools.extern import pyparsing [as 別名]
# 或者: from setuptools.extern.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:ali5h,項目名稱:rules_pip,代碼行數:28,代碼來源:requirements.py

示例4: __init__

# 需要導入模塊: from setuptools.extern import pyparsing [as 別名]
# 或者: from setuptools.extern.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:ali5h,項目名稱:rules_pip,代碼行數:10,代碼來源:markers.py


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