async def validate_repository(self): """Validate.""" await self.common_validate() # Custom step 1: Validate content. if self.repository_manifest: if self.data.content_in_root: self.content.path.remote = "" if self.content.path.remote == "apps": self.data.domain = get_first_directory_in_directory( self.tree, self.content.path.remote) self.content.path.remote = f"apps/{self.data.name}" compliant = False for treefile in self.treefiles: if treefile.startswith(f"{self.content.path.remote}" ) and treefile.endswith(".cs"): compliant = True break if not compliant: raise HacsException( f"Repostitory structure for {self.ref.replace('tags/','')} is not compliant" ) # Handle potential errors if self.validate.errors: for error in self.validate.errors: if not self.hacs.status.startup: self.logger.error(error) return self.validate.success
async def validate_repository(self): """Validate.""" await self.common_validate() # Custom step 1: Validate content. if self.data.content_in_root: self.content.path.remote = "" if self.content.path.remote == "custom_components": name = get_first_directory_in_directory(self.tree, "custom_components") if name is None: raise HacsException( f"Repostitory structure for {self.ref.replace('tags/','')} is not compliant" ) self.content.path.remote = f"custom_components/{name}" try: await get_integration_manifest(self) except HacsException as exception: if self.hacs.system.action: raise HacsException(f"::error:: {exception}") from exception self.logger.error("%s %s", self, exception) # Handle potential errors if self.validate.errors: for error in self.validate.errors: if not self.hacs.status.startup: self.logger.error("%s %s", self, error) return self.validate.success
def test_not_valid(): tree = [ AIOGitHubAPIRepositoryTreeContent( { "path": ".github/path/file.file", "type": "tree" }, "test/test", "master") ] assert get_first_directory_in_directory(tree, "test") is None
async def update_repository(self, ignore_issues=False): """Update.""" await self.common_update(ignore_issues) # Get appdaemon objects. if self.repository_manifest: if self.data.content_in_root: self.content.path.remote = "" if self.content.path.remote == "apps": self.data.domain = get_first_directory_in_directory( self.tree, self.content.path.remote) self.content.path.remote = f"apps/{self.data.name}" # Set local path self.content.path.local = self.localpath
def test_valid(): tree = [ AIOGitHubAPIRepositoryTreeContent({ "path": "test", "type": "tree" }, "test/test", "master"), AIOGitHubAPIRepositoryTreeContent({ "path": "test/path", "type": "tree" }, "test/test", "master"), AIOGitHubAPIRepositoryTreeContent( { "path": "test/path/sub", "type": "tree" }, "test/test", "master"), ] assert get_first_directory_in_directory(tree, "test") == "path"
async def update_repository(self, ignore_issues=False): """Update.""" await self.common_update(ignore_issues) if self.data.content_in_root: self.content.path.remote = "" if self.content.path.remote == "custom_components": name = get_first_directory_in_directory(self.tree, "custom_components") self.content.path.remote = f"custom_components/{name}" try: await get_integration_manifest(self) except HacsException as exception: self.logger.error("%s %s", self, exception) # Set local path self.content.path.local = self.localpath