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.action: raise HacsException(exception) self.logger.error(exception) # Handle potential errors if self.validate.errors: for error in self.validate.errors: if not self.hacs.system.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.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.system.status.startup: self.logger.error(error) return self.validate.success
def test_not_valid(): tree = [ AIOGithubTreeContent( {"path": ".github/path/file.file", "type": "tree"}, "test/test", "master" ) ] assert get_first_directory_in_directory(tree, "test") is None
def test_valid(): tree = [ AIOGithubTreeContent({"path": "test", "type": "tree"}, "test/test", "master"), AIOGithubTreeContent( {"path": "test/path", "type": "tree"}, "test/test", "master" ), AIOGithubTreeContent( {"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) # 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
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(exception) # Set local path self.content.path.local = self.localpath
async def update_repository(self): """Update.""" if self.hacs.github.ratelimits.remaining == 0: return await self.common_update() # 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
async def update_repository(self): """Update.""" if self.hacs.github.ratelimits.remaining == 0: return await self.common_update() 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(exception) # Set local path self.content.path.local = self.localpath