(location, content)
return os.path.exists(location)
Save files.
Save files.
Save files .
async def async_save_file(location, content):
    """Save files."""
    logger = Logger("hacs.download.save")
    logger.debug(f"Saving {location}")
    mode = "w"
    encoding = "utf-8"
    errors = "ignore"

    if not isinstance(content, str):
        mode = "wb"
        encoding = None
        errors = None

    try:
        async with aiofiles.open(
            location, mode=mode, encoding=encoding, errors=errors
        ) as outfile:
            await outfile.write(content)
            outfile.close()

        # Create gz for .js files
        if os.path.isfile(location):
            if location.endswith(".js") or location.endswith(".css"):
                with open(location, "rb") as f_in:
                    with gzip.open(location + ".gz", "wb") as f_out:
                        shutil.copyfileobj(f_in, f_out)

    except Exception as error:  # pylint: disable=broad-except
        msg = "Could not write data to {} - {}".format(location, error)
        logger.debug(msg)

    return os.path.exists(location)
async def async_save_file ( location , content ) : logger = Logger ( "hacs.download.save" ) logger . debug ( f"Saving {location}" ) mode = "w" encoding = "utf-8" errors = "ignore" if not isinstance ( content , str ) : mode = "wb" encoding = None errors = None try : async with aiofiles . open ( location , mode = mode , encoding = encoding , errors = errors ) as outfile : await outfile . write ( content ) outfile . close ( ) # Create gz for .js files if os . path . isfile ( location ) : if location . endswith ( ".js" ) or location . endswith ( ".css" ) : with open ( location , "rb" ) as f_in : with gzip . open ( location + ".gz" , "wb" ) as f_out : shutil . copyfileobj ( f_in , f_out ) except Exception as error : # pylint: disable=broad-except msg = "Could not write data to {} - {}" . format ( location , error ) logger . debug ( msg ) return os . path . exists ( location )