def contians_attribute(self, attribute):
        """
        Returns how many cards in the deck have the specified attribute.

        This method requires a library to be stored in the deck instance and
        will return `None` if there is no library.
        """
        if self.library is None:
            return 0

        load = self.library.load_card
        matches = 0
        for code in self.cards:
            card = load(code)
            if card.has_attribute(attribute):
                matches += 1
        return matches
Returns how many cards in the deck have the specified attribute.

        This method requires a library to be stored in the deck instance and
        will return `None` if there is no library.