def coerce(cls, string):
        """Create a :class:`Requirement` object from a given package spec."""
        match = re.match(cls.spec_regex, string)
        if not match:
            raise InvalidRequirementSpecError("could not parse requirement")
        package = match.group(1)
        if all(match.group(2, 3)):
            version = "".join(match.group(2, 3))
        else:
            version = None
        return cls(package, version)
def __init__(self, resolver, proxy_type, key):
        if proxy_type == "file":
            self._method = resolver.get_file_content
        elif proxy_type == "param":
            self._method = resolver.get_parameter_value
        elif proxy_type == "secret":
            self._method = resolver.get_secret_value
        elif proxy_type == "bucket_file":
            self._method = resolver.get_bucket_file
        else:
            raise ValueError("Unknown proxy type %s", proxy_type)
        self._key = key