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 _on_item_widget_size_allocate(self, item_widget, allocation, item):
    if item in self._items_allocations:
      self._update_width(allocation.width - self._items_allocations[item].width)
      self._update_height(allocation.height - self._items_allocations[item].height)
    else:
      self._update_width(allocation.width)
      self._update_height(allocation.height + self._item_spacing)