def write(pkg: ArchPackage): data = pkg.get_data_to_cache() Path(pkg.get_disk_cache_path()).mkdir(parents=True, exist_ok=True) with open(pkg.get_disk_data_path(), 'w+') as f: f.write(json.dumps(data))
def write(pkg: ArchPackage, desktop_file: Optional[str] = None, command: Optional[str] = None, icon: Optional[str] = None, maintainer: Optional[str] = None, after_written: Optional[callable] = None): pkg.desktop_entry = desktop_file pkg.command = command pkg.icon_path = icon if maintainer and not pkg.maintainer: pkg.maintainer = maintainer Path(pkg.get_disk_cache_path()).mkdir(parents=True, exist_ok=True) data = pkg.get_data_to_cache() with open(pkg.get_disk_data_path(), 'w+') as f: f.write(json.dumps(data)) if after_written: after_written(pkg.name)
def clean_cache_for(self, pkg: ArchPackage): if os.path.exists(pkg.get_disk_cache_path()): shutil.rmtree(pkg.get_disk_cache_path())