parameters: (self)
return_statement: return True
docstring: Check the local directory.
docstring_summary: Check the local directory.
docstring_tokens: Check the local directory .
function: async def remove_local_directory(self):
          """Check the local directory."""
          from asyncio import sleep
  
          try:
              if self.data.category == "python_script":
                  local_path = f"{self.content.path.local}/{self.data.name}.py"
              elif self.data.category == "theme":
                  if os.path.exists(
                      f"{self.hacs.core.config_path}/{self.hacs.configuration.theme_path}/{self.data.name}.yaml"
                  ):
                      os.remove(
                          f"{self.hacs.core.config_path}/{self.hacs.configuration.theme_path}/{self.data.name}.yaml"
                      )
                  local_path = self.content.path.local
              elif self.data.category == "integration":
                  if not self.data.domain:
                      self.logger.error("%s Missing domain", self)
                      return False
                  local_path = self.content.path.local
              else:
                  local_path = self.content.path.local
  
              if os.path.exists(local_path):
                  if not is_safe_to_remove(local_path):
                      self.logger.error("%s Path %s is blocked from removal", self, local_path)
                      return False
                  self.logger.debug("%s Removing %s", self, local_path)
  
                  if self.data.category in ["python_script"]:
                      os.remove(local_path)
                  else:
                      shutil.rmtree(local_path)
  
                  while os.path.exists(local_path):
                      await sleep(1)
              else:
                  self.logger.debug(
                      "%s Presumed local content path %s does not exist", self, local_path
                  )
  
          except (Exception, BaseException) as exception:
              self.logger.debug("%s Removing %s failed with %s", self, local_path, exception)
              return False
          return True
function_tokens: async def remove_local_directory ( self ) : from asyncio import sleep try : if self . data . category == "python_script" : local_path = f"{self.content.path.local}/{self.data.name}.py" elif self . data . category == "theme" : if os . path . exists ( f"{self.hacs.core.config_path}/{self.hacs.configuration.theme_path}/{self.data.name}.yaml" ) : os . remove ( f"{self.hacs.core.config_path}/{self.hacs.configuration.theme_path}/{self.data.name}.yaml" ) local_path = self . content . path . local elif self . data . category == "integration" : if not self . data . domain : self . logger . error ( "%s Missing domain" , self ) return False local_path = self . content . path . local else : local_path = self . content . path . local if os . path . exists ( local_path ) : if not is_safe_to_remove ( local_path ) : self . logger . error ( "%s Path %s is blocked from removal" , self , local_path ) return False self . logger . debug ( "%s Removing %s" , self , local_path ) if self . data . category in [ "python_script" ] : os . remove ( local_path ) else : shutil . rmtree ( local_path ) while os . path . exists ( local_path ) : await sleep ( 1 ) else : self . logger . debug ( "%s Presumed local content path %s does not exist" , self , local_path ) except ( Exception , BaseException ) as exception : self . logger . debug ( "%s Removing %s failed with %s" , self , local_path , exception ) return False return True