コード例 #1
0
ファイル: config.py プロジェクト: brunogola/skink
 def register_inheritors(self, property, root_path, base_type, lifestyle_type = "UNKNOWN", include_base = False):
     if (lifestyle_type == "UNKNOWN"): lifestyle_type = self.default_lifestyle_type
     self.assert_valid_lifestyle_type(lifestyle_type)        
     
     all_classes = []
     
     for module_path in common.locate("*.py", root=root_path, recursive=False):
         module = reflection.get_module_from_path(module_path)
         classes = reflection.get_classes_for_module(module)
         
         for cls in classes:
             should_include = include_base and cls.__name__ == base_type.__name__
             should_include = should_include or (cls.__bases__ is (list, tuple) and base_type.__name__ in [klass.__name__ for klass in cls.__bases__])
             if should_include:
                 all_classes.append(cls)
     
     component_definition = "indirect", lifestyle_type, all_classes, None, None
コード例 #2
0
ファイル: config.py プロジェクト: heynemann/pyoc
 def register_inheritors(self, property, root_path, base_type, lifestyle_type = "UNKNOWN", include_base = False):
     if (lifestyle_type == "UNKNOWN"): lifestyle_type = self.default_lifestyle_type
     self.assert_valid_lifestyle_type(lifestyle_type)        
     
     all_classes = []
     
     for module_path in common.locate("*.py", root=root_path, recursive=False):
         try:
             module = reflection.get_module_from_path(module_path)
         except UnicodeDecodeError, err:
             print err
             raise
         classes = reflection.get_classes_for_module(module)
         
         for cls in classes:
             should_include = include_base and cls.__name__ == base_type.__name__
             should_include = should_include or (isinstance(cls.__bases__, (list, tuple)) and base_type.__name__ in [klass.__name__.replace("__init__.","") for klass in cls.__bases__])
             if should_include:
コード例 #3
0
ファイル: config.py プロジェクト: heynemann/pyoc
 def register_files(self, property, root_path, pattern, lifestyle_type = "UNKNOWN"):
     if (lifestyle_type == "UNKNOWN"): lifestyle_type = self.default_lifestyle_type
     self.assert_valid_lifestyle_type(lifestyle_type)        
     
     all_classes = []
     for module_path in common.locate(pattern, root=root_path):
         module = reflection.get_module_from_path(module_path)
         
         class_name = common.camel_case(module.__name__)
         cls = reflection.get_class_for_module(module, class_name)
         
         if cls == None:
             raise AttributeError("The class %s could not be found in file %s. Please make sure that the class has the same name as the file, but Camel Cased." % (class_name, module_path))
         
         all_classes.append(cls)
     
     component_definition = "indirect", lifestyle_type, all_classes, None, None
     self.components[property] = component_definition
コード例 #4
0
ファイル: config.py プロジェクト: brunogola/skink
 
 def execute_config_file(self, root_path, filename):
     module = reflection.get_module_from_path(os.path.join(root_path, filename))
     func = getattr(module, "config")
     config_helper = FileConfig.ContainerConfigHelper(self)