我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用pkg_resources.invalid_marker()。
def _check_extra(extra, reqs): name, sep, marker = extra.partition(':') if marker and pkg_resources.invalid_marker(marker): raise DistutilsSetupError("Invalid environment marker: " + marker) list(pkg_resources.parse_requirements(reqs))
def check_extras(dist, attr, value): """Verify that extras_require mapping is valid""" try: for k,v in value.items(): if ':' in k: k,m = k.split(':',1) if pkg_resources.invalid_marker(m): raise DistutilsSetupError("Invalid environment marker: "+m) list(pkg_resources.parse_requirements(v)) except (TypeError,ValueError,AttributeError): raise DistutilsSetupError( "'extras_require' must be a dictionary whose values are " "strings or lists of strings containing valid project/version " "requirement specifiers." )
def check_extras(dist, attr, value): """Verify that extras_require mapping is valid""" try: for k, v in value.items(): if ':' in k: k, m = k.split(':', 1) if pkg_resources.invalid_marker(m): raise DistutilsSetupError("Invalid environment marker: " + m) list(pkg_resources.parse_requirements(v)) except (TypeError, ValueError, AttributeError): raise DistutilsSetupError( "'extras_require' must be a dictionary whose values are " "strings or lists of strings containing valid project/version " "requirement specifiers." )
def marker_passes(marker): """ Given an environment marker, return True if the marker is valid and matches this environment. """ return ( not marker or not pkg_resources.invalid_marker(marker) and pkg_resources.evaluate_marker(marker) )
def _check_extra(extra, reqs): name, sep, marker = extra.partition(':') if marker and pkg_resources.invalid_marker(marker): raise DistutilsSetupError("Invalid environment marker: " + marker) # extras requirements cannot themselves have markers parsed = pkg_resources.parse_requirements(reqs) marked_reqs = filter(operator.attrgetter('marker'), parsed) bad_req = next(marked_reqs, None) if bad_req: tmpl = ( "'extras_require' requirements cannot include " "environment markers, in {name!r}: '{bad_req!s}'" ) raise DistutilsSetupError(tmpl.format(**locals()))