#!/usr/bin/env python """ schemes/__init__.py - Emano Schemes Class Author: Sean B. Palmer, inamidst.com Source: http://inamidst.com/emano/ """ class Schemes(object): def __init__(self): self.__schemes = {} def __getitem__(self, item): if self.__schemes.has_key(item): return self.__schemes[item] try: module = getattr(__import__('schemes.' + item), item) except ImportError: return False self.__schemes[item] = module return module def read(self, scheme): module = self[scheme] if not module: return False if not hasattr(module, 'read'): return False return getattr(module, 'read') def write(self, scheme): module = self[scheme] if not module: return False if not hasattr(module, 'write'): return False return getattr(module, 'write') if __name__=="__main__": main()