Viewing File: /lib/python3.6/site-packages/dnf-plugins/__pycache__/generate_completion_cache.cpython-36.pyc

3

�gt`l�@s^ddlmZddlmZddlmZddlmZddlZddlZ	ddl
Z
Gdd�dej�ZdS)�)�absolute_import)�unicode_literals)�ucd)�loggerNcs<eZdZdZ�fdd�Zedd��Zdd�Zdd	�Z�Z	S)
�BashCompletionCacheZgenerate_completion_cachecs"tt|�j||�||_d|_dS)Nz/var/cache/dnf/packages.db)�superr�__init__�base�
cache_file)�selfr	Zcli)�	__class__��//usr/lib/python3.6/generate_completion_cache.pyrszBashCompletionCache.__init__cCstjd|�dS)NzCompletion plugin: %s)r�debug)�msgr
r
r�_out$szBashCompletionCache._outcCsd}x,|jjj�D]}|jdk	r|jjrd}PqWtjj|j�sF|r�y~t	j
|j��h}|jd�|j�}|j
d�|j
d�|j
d�|jjj�j�}dd	�|D�}|jd
|�|j�WdQRXWn6t	jk
r�}z|jdt|��WYdd}~XnXdS)z& Generate cache of available packages FNTzGenerating 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|�g�qS)�src)�arch�str)�.0�xr
r
r�
<listcomp>@sz,BashCompletionCache.sack.<locals>.<listcomp>z*insert or ignore into available values (?)z Can't write completion cache: %s)r	ZreposZiter_enabledZmetadata�fresh�os�path�existsr
�sqlite3�connectr�cursor�execute�sack�queryZ	available�executemany�commit�OperationalErrorr)rrZrepo�conn�curZ
avail_pkgsZavail_pkgs_insert�er
r
rr (s,

zBashCompletionCache.sackcCs�|js
dSy�tj|j��n}|jd�|j�}|jd�|jd�|jd�tjj	|j
�j�j�}dd�|D�}|j
d|�|j�WdQRXWn6tjk
r�}z|jd	t|��WYdd}~XnXdS)
z& Generate cache of installed packages NzGenerating completion cache...z/create table if not exists installed (pkg TEXT)zAcreate unique index if not exists pkg_installed ON installed(pkg)zdelete from installedcSs g|]}|jdkrt|�g�qS)r)rr)rrr
r
rrVsz3BashCompletionCache.transaction.<locals>.<listcomp>z*insert or ignore into installed values (?)z Can't write completion cache: %s)�transactionrrr
rrr�dnfr Z_rpmdb_sackr	r!Z	installedr"r#r$r)rr%r&Z	inst_pkgsZinst_pkgs_insertr'r
r
rr(Gs"


zBashCompletionCache.transaction)
�__name__�
__module__�__qualname__�namer�staticmethodrr r(�
__classcell__r
r
)rrrs
r)
Z
__future__rrZdnf.i18nrZdnfpluginscorerr)Zos.pathrrZPluginrr
r
r
r�<module>s
Back to Directory File Manager
<