(self, validate, directory_path, local_directory, ref)
return validate
Download the content of a directory.
Download the content of a directory.
Download the content of a directory .
async def download_content(self, validate, directory_path, local_directory, ref):
        """Download the content of a directory."""
        try:
            # Get content
            if self.content.single:
                contents = self.content.objects
            else:
                contents = await self.repository_object.get_contents(
                    directory_path, self.ref
                )

            for content in contents:
                if content.type == "dir" and self.content.path.remote != "":
                    await self.download_content(
                        validate, content.path, local_directory, ref
                    )
                    continue
                if self.information.category == "plugin":
                    if not content.name.endswith(".js"):
                        if self.content.path.remote != "dist":
                            continue

                self.logger.debug(f"Downloading {content.name}")

                filecontent = await async_download_file(self.hass, content.download_url)

                if filecontent is None:
                    validate.errors.append(f"[{content.name}] was not downloaded.")
                    continue

                # Save the content of the file.
                if self.content.single:
                    local_directory = self.content.path.local
                else:
                    _content_path = content.path
                    _content_path = _content_path.replace(
                        f"{self.content.path.remote}/", ""
                    )

                    local_directory = f"{self.content.path.local}/{_content_path}"
                    local_directory = local_directory.split("/")
                    del local_directory[-1]
                    local_directory = "/".join(local_directory)

                # Check local directory
                pathlib.Path(local_directory).mkdir(parents=True, exist_ok=True)

                local_file_path = f"{local_directory}/{content.name}"
                result = await async_save_file(local_file_path, filecontent)
                if result:
                    self.logger.info(f"download of {content.name} complete")
                    continue
                validate.errors.append(f"[{content.name}] was not downloaded.")

        except SystemError:
            pass
        return validate
async def download_content ( self , validate , directory_path , local_directory , ref ) : try : # Get content if self . content . single : contents = self . content . objects else : contents = await self . repository_object . get_contents ( directory_path , self . ref ) for content in contents : if content . type == "dir" and self . content . path . remote != "" : await self . download_content ( validate , content . path , local_directory , ref ) continue if self . information . category == "plugin" : if not content . name . endswith ( ".js" ) : if self . content . path . remote != "dist" : continue self . logger . debug ( f"Downloading {content.name}" ) filecontent = await async_download_file ( self . hass , content . download_url ) if filecontent is None : validate . errors . append ( f"[{content.name}] was not downloaded." ) continue # Save the content of the file. if self . content . single : local_directory = self . content . path . local else : _content_path = content . path _content_path = _content_path . replace ( f"{self.content.path.remote}/" , "" ) local_directory = f"{self.content.path.local}/{_content_path}" local_directory = local_directory . split ( "/" ) del local_directory [ - 1 ] local_directory = "/" . join ( local_directory ) # Check local directory pathlib . Path ( local_directory ) . mkdir ( parents = True , exist_ok = True ) local_file_path = f"{local_directory}/{content.name}" result = await async_save_file ( local_file_path , filecontent ) if result : self . logger . info ( f"download of {content.name} complete" ) continue validate . errors . append ( f"[{content.name}] was not downloaded." ) except SystemError : pass return validate