Created
August 6, 2014 18:21
-
-
Save sapamja/6ed0d09d32396c6f43b9 to your computer and use it in GitHub Desktop.
abc.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import abc | |
| class PluginBase(object): | |
| __metaclass__ = abc.ABCMeta | |
| def __init__(self): | |
| self.base = 'base_info' | |
| @abc.abstractmethod | |
| def load(self, input): | |
| """Retrieve data from the input source and return an object.""" | |
| return | |
| @abc.abstractmethod | |
| def save(self, output, data): | |
| """Save the data object to the output.""" | |
| return | |
| class SubclassImplementation(PluginBase): | |
| def __init__(self): | |
| super(SubclassImplementation, self).__init__() | |
| self.base = 'james' | |
| def load(self, input): | |
| print self.base | |
| return True | |
| def asave(self, output, data): | |
| return True | |
| if __name__ == '__main__': | |
| print 'Subclass:', issubclass(SubclassImplementation, PluginBase) | |
| print 'Instance:', isinstance(SubclassImplementation(), PluginBase) | |
| obj = SubclassImplementation() | |
| obj.load('input') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment