Пример #1
0
    def remove_dependency(self: T, dependency: Union[Dependency, str]) -> T:
        if isinstance(dependency, Dependency):
            self.__dependencies.remove(dependency)
        elif isinstance(dependency, str):
            dependency = ConfigBuilder.get_dependency(dependency)
            self.__dependencies.remove(dependency)

        return self
Пример #2
0
    def create(id: str, force_create: bool = False) -> T:
        ValueChecker.validate_id(id)

        dependency = None if force_create else ConfigBuilder.get_dependency(id)
        if None is dependency:
            dependency = ServerDependency(id)
            ConfigBuilder.add_dependency(id, dependency)

        return dependency
Пример #3
0
    def add_dependency(self: T, dependency: Union[Dependency, str]) -> T:
        if isinstance(dependency, Dependency):
            if dependency not in self.__dependencies:
                self.__dependencies.append(dependency)
        elif isinstance(dependency, str):
            dependency = ConfigBuilder.get_dependency(dependency)
            if None is dependency:
                raise Exception('Dependency does not exist yet!')
            if dependency not in self.__dependencies:
                self.__dependencies.append(dependency)
        else:
            raise Exception('Can only add Dependency or id of Dependency!')

        return self