Esempio n. 1
0
    def __find_implementations():
        """Returns all the concrete subclasses of MetadataExtractor.

        """
        implementations = {}
        for implementation in all_subclasses(MetadataExtractor):
            try:
                implementations[implementation.feature_name()] = implementation
            except NotImplementedError:
                pass
        return implementations
Esempio n. 2
0
    def __find_implementations():
        """Returns all the concrete subclasses of MetadataExtractor.

        """
        implementations = {}
        for implementation in all_subclasses(MetadataExtractor):
            try:
                implementations[implementation.feature_name()] = implementation
            except NotImplementedError:
                pass
        return implementations
Esempio n. 3
0
    def test_all_subclasses(self):
        class Root(object):
            pass

        class AB(Root):
            pass

        class ABC(AB):
            pass

        class AD(Root):
            pass

        class ABAD(AB, AD):
            pass

        class ABADE(ABAD):
            pass

        self.assertTrue(all_subclasses(Root), set([AB, ABC, AD, ABAD, ABADE]))
        self.assertEqual(all_subclasses(ABADE), set())
Esempio n. 4
0
    def test_all_subclasses(self):
        class Root(object):
            pass

        class AB(Root):
            pass

        class ABC(AB):
            pass

        class AD(Root):
            pass

        class ABAD(AB, AD):
            pass

        class ABADE(ABAD):
            pass

        self.assertTrue(all_subclasses(Root), set([AB, ABC, AD, ABAD, ABADE]))
        self.assertTrue(all_subclasses(ABADE) == set())
Esempio n. 5
0
    def test_all_subclasses(self):
        class Root(object):
            pass

        class AB(Root):
            pass

        class ABC(AB):
            pass

        class AD(Root):
            pass

        class ABAD(AB, AD):
            pass

        class ABADE(ABAD):
            pass

        self.assertItemsEqual(all_subclasses(Root), [AB, ABC, AD, ABAD, ABADE])
        self.assertSetEqual(all_subclasses(ABADE), set())
Esempio n. 6
0
    def _implementations(cls):
        """Returns all the concrete subclasses of MetadataExtractor.

        """
        if cls.__implementations:
            return cls.__implementations

        cls.__implementations = {}
        for implementation in all_subclasses(MetadataExtractor):
            try:
                feature_name = implementation.feature_name()
                cls.__implementations[feature_name] = implementation
            except NotImplementedError:
                pass
        return cls.__implementations
Esempio n. 7
0
File: api.py Progetto: c-w/Gutenberg
    def _implementations(cls):
        """Returns all the concrete subclasses of MetadataExtractor.

        """
        if cls.__implementations:
            return cls.__implementations

        cls.__implementations = {}
        for implementation in all_subclasses(MetadataExtractor):
            try:
                feature_name = implementation.feature_name()
                cls.__implementations[feature_name] = implementation
            except NotImplementedError:
                pass
        return cls.__implementations