def configure(self): mrbase_class = loadclassname(os.environ['dumbo_mrbase_class']) mapper = self.mapper if type(mapper) in (types.ClassType, type): mappercls = type('DumboMapper', (mapper, mrbase_class), {}) mapper = mappercls() if hasattr(mapper, 'map'): mapper = mapper.map if hasattr(mapper, 'configure'): mapper.configure() if hasattr(mapper, 'close'): self.closefunc = mapper.close self.mapper = mapper
def configure(self): mrbase_class = loadclassname(os.environ['dumbo_mrbase_class']) mappers, closefuncs = [], [] for pattern, mapper in self.mappers: if type(mapper) in (types.ClassType, type): mappercls = type('DumboMapper', (mapper, mrbase_class), {}) mapper = mappercls() if hasattr(mappercls, 'map'): mapper = mapper.map if hasattr(mapper, 'configure'): mapper.configure() if hasattr(mapper, 'close'): closefuncs.append(mapper.close) mappers.append((pattern, mapper)) self.mappers = mappers self.closefuncs = closefuncs
def configure(self): mrbase_class = loadclassname(os.environ['dumbo_mrbase_class']) mapper = self.mapper if type(mapper) in (types.ClassType, type): mappercls = type('DumboMapper', (mapper, mrbase_class), {}) mapper = mappercls() if hasattr(mapper, 'map'): mapper = mapper.map if hasattr(mapper, 'configure'): mapper.configure() if hasattr(mapper, 'close'): self.closefunc = mapper.close mapper_call = mapper if isinstance(mapper_call, mrbase_class): mapper_call = mapper.__call__ self.mapper = mapper if not inspect.getargspec(mapper_call).keywords: self.mapper = lambda key, value, **kwargs: mapper(key, value)