a &cl@s^ddlmZddlmZddlmZddlmZddlZddlZ ddl Z Gdddej Z dS))absolute_import)unicode_literals)ucd)loggerNcs<eZdZdZfddZeddZddZdd ZZ S) BashCompletionCacheZgenerate_completion_cachecs"tt|||||_d|_dS)Nz/var/cache/dnf/packages.db)superr__init__base cache_file)selfr Zcli __class__I/usr/lib/python3.9/site-packages/dnf-plugins/generate_completion_cache.pyrszBashCompletionCache.__init__cCstd|dS)NzCompletion plugin: %s)rdebug)msgrrr_out$szBashCompletionCache._outc Csd}|jjD]}|jdur|jjrd}q0qtj|jrD|rzt |jr}| d| }| d| d| d|jj}dd |D}|d ||Wdn1s0YWn:t jy}z| d t|WYd}~n d}~00dS) z& Generate cache of available packages FNTGenerating completion cache...z/create table if not exists available (pkg TEXT)zAcreate unique index if not exists pkg_available ON available(pkg)zdelete from availablecSs g|]}|jdkrt|gqSsrcZarchstr.0xrrr @z,BashCompletionCache.sack..z*insert or ignore into available values (?) Can't write completion cache: %s)r ZreposZ iter_enabledmetadatafreshospathexistsr sqlite3connectrcursorexecutesackqueryZ available executemanycommitOperationalErrorr)r rZrepoconncurZ avail_pkgsZavail_pkgs_inserterrrr'(s2  *zBashCompletionCache.sackc Cs|js dSzt|jx}|d|}|d|d|dtj |j  }dd|D}| d||Wdn1s0YWn8tjy}z|d t|WYd}~n d}~00dS) z& Generate cache of installed packages Nrz/create table if not exists installed (pkg TEXT)zAcreate unique index if not exists pkg_installed ON installed(pkg)zdelete from installedcSs g|]}|jdkrt|gqSrrrrrrrVrz3BashCompletionCache.transaction..z*insert or ignore into installed values (?)r) transactionr#r$r rr%r&dnfr'Z _rpmdb_sackr r(Z installedr)r*r+r)r r,r-Z inst_pkgsZinst_pkgs_insertr.rrrr/Gs&   *zBashCompletionCache.transaction) __name__ __module__ __qualname__namer staticmethodrr'r/ __classcell__rrr rrs   r) Z __future__rrZdnf.i18nrZdnfpluginscorerr0Zos.pathr r#ZPluginrrrrrs