def add(self, elem, replace=False):
        """Add a requirement.

        :param elem: a string or :class:`Requirement` instance.
        :param replace: if `True`, packages in the set with the same name will
            be removed first.
        """
        if isinstance(elem, text_type):
            elem = Requirement.coerce(elem)
        if replace and elem in self:
            self.remove(elem)
        super(Requirements, self).add(elem)
def deserialize(self, value, display=False):
        value = decode(value).strip()
        validators.validate_required(value, self._required)
        if not value:
            return None

        socket_path = path.get_unix_socket_path(value)
        if socket_path is not None:
            path_str = Path(not self._required).deserialize(socket_path)
            return f"unix:{path_str}"

        try:
            socket.getaddrinfo(value, None)
        except OSError:
            raise ValueError("must be a resolveable hostname or valid IP")

        return value