def reload_entities_data(dir=None): if dir is None: for data_path in ENTITIES_DATA_PATH.rglob("*.ini"): parts = data_path.relative_to(ENTITIES_DATA_PATH).parts path = ENTITIES_DATA_PATH / parts[0] / parts[-1] class_name = path.stem data_paths[class_name].add(str(path)) else: data_path = ENTITIES_DATA_PATH / dir if data_path.exists() and data_path.is_dir(): for path in data_path.rglob("*.ini"): data_paths[path.stem].add(str(data_path / path.name)) else: raise ValueError( "Invalid data path: {path}".format(path=data_path)) for classname in factory_dictionary: base_entity = BaseEntity.find(classname) if base_entity is not None: datamap = base_entity.datamap while datamap: class_name = datamap.class_name if class_name not in server_classes: server_classes._get_server_class(class_name, datamap) datamap = datamap.base update_data() if (data_paths and on_entity_created not in on_entity_created_listener_manager): on_entity_created_listener_manager.register_listener(on_entity_created)
def _get_datamap(classname): """Return the DataMap object for the given entity classname.""" # Check existing entities at first entity = BaseEntity.find(classname) if entity is not None: return entity.datamap # We haven't found an entity. Let's create it temporarily entity = BaseEntity.create(classname) datamap = entity.datamap entity.remove() return datamap