''' Overwatch Aggregate Object type TODO Method overrides: _common gets renamed to _call_all and we add _call_last. ''' class ModuleCollision(Exception): def __init__(self, colliding_module_name, resident_module_names, item_type, items): self.colliding_module_name = colliding_module_name self.resident_module_names = resident_module_names self.item_type = item_type self.items = items def __str__(self): if self.item_type == 'name': return "Unable to link module '%s': name already present in Aggregate." %(self.colliding_module_name) else: return "Unable to link module '%s': %s(s) '%s' already provided by module(s) '%s'." %(self.colliding_module_name, self.item_type, "', '".join(self.items), "', '".join(self.resident_module_names)) class ModuleDependencyError(Exception): def __init__(self, module_name, dependencies, unlink=False): self.module_name = module_name self.dependencies = dependencies self.unlink = unlink def __str__(self): if self.unlink: return "Unable to unlink module '%s': Aggregate depends on its export(s) '%s'." %(self.module_name, "', '".join(self.dependencies)) else: return "Unable to link module '%s': requirement '%s' unsatisfied by Aggregate." %(self.module_name, "', '".join(self.dependencies)) class CommonMethodMissing(Exception): def __init__(self, method_name, module_name): self.method_name = method_name self.module_name = module_name def __str__(self): return "Unable to link module '%s': method '%s' (declared as common) does not exist in module." %( self.module_name, self.method_name) class ModuleDoesntExist(Exception): def __init__(self, module_name): self.module_name = module_name def __str__(self): return "Unable to unlink module '%s': not linked to Aggregate." %(self.module_name)