def add(self, kind, item): """ Adds any supported kind of a resource to the repository :param kind: specific kind of the repository resource :type kind: :py:class:`leapp.repository.definition.DefinitionKind` :param item: Item that will be added :type item: :py:class:`leapp.repository.actor_definition.ActorDefiniton` or str """ self.log.debug( 'Adding %s - %s', kind.name, item.directory if isinstance(item, ActorDefinition) else item) if kind not in DefinitionKind.REPO_WHITELIST: raise UnsupportedDefinitionKindError( 'Repositories do not support {kind}.'.format(kind=kind.name)) # Except for ActorDefinitions all items added are paths and are supposed to be relative paths to the repository if not isinstance(item, ActorDefinition): full_path = os.path.join(self._repo_dir, item) if not os.path.exists(full_path): self.log.error( "Attempted to add %s, which is not in the repositories path", item) raise RepoItemPathDoesNotExistError(kind, item, full_path) item = full_path self._definitions.setdefault(kind, []).append(item)
def add(self, kind, path): if kind not in DefinitionKind.ACTOR_WHITELIST: self.log.error( "Attempt to add item type %s to actor that is not supported", kind.name) raise UnsupportedDefinitionKindError( 'Actors do not support {kind}.'.format(kind=kind.name)) self._definitions.setdefault(kind, []).append(path)
def add(self, kind, path): """ Adds any kind of actor resource to the Definition :param kind: kind of resource added :type kind: str :param path: path to the added resource :type path: str """ if kind not in DefinitionKind.ACTOR_WHITELIST: self.log.error("Attempt to add item type %s to actor that is not supported", kind.name) raise UnsupportedDefinitionKindError('Actors do not support {kind}.'.format(kind=kind.name)) self._definitions.setdefault(kind, []).append(path)
def add(self, kind, item): self.log.debug( 'Adding %s - %s', kind.name, item.directory if isinstance(item, ActorDefinition) else item) if kind not in DefinitionKind.REPO_WHITELIST: raise UnsupportedDefinitionKindError( 'Repositories do not support {kind}.'.format(kind=kind.name)) # Except for ActorDefinitions all items added are paths and are supposed to be relative paths to the repository if not isinstance(item, ActorDefinition): full_path = os.path.join(self._repo_dir, item) if not os.path.exists(full_path): self.log.error( "Attempted to add %s which is not in the repositories path", item) raise RepoItemPathDoesNotExistError(kind, item, full_path) item = full_path self._definitions.setdefault(kind, []).append(item)