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 render(self, context):
        try:
            if self.params:
                params = template.Variable(self.params).resolve(context)
            else:
                params = {}

            # try matching an address string literal
            email_literal = self.email.strip().lower()
            if EMAIL_RE.match(email_literal):
                email = email_literal
            # treat as a variable
            else:
                email = template.Variable(self.email).resolve(context)
        except template.VariableDoesNotExist:
            return ''

        # now, we generate the gravatar url
        return _build_gravatar_url(email, params)