<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
gt`l                 @   s^   d dl mZ d dl mZ d dlmZ d dlmZ d dlZd dlZ	d dl
Z
G dd dejZdS )    )absolute_import)unicode_literals)ucd)loggerNc                   s<   e Zd ZdZ fddZedd Zdd Zdd	 Z  Z	S )
BashCompletionCacheZgenerate_completion_cachec                s"   t t| j|| || _d| _d S )Nz/var/cache/dnf/packages.db)superr   __init__base
cache_file)selfr	   Zcli)	__class__ //usr/lib/python3.6/generate_completion_cache.pyr      s    zBashCompletionCache.__init__c             C   s   t jd|  d S )NzCompletion plugin: %s)r   debug)msgr   r   r   _out$   s    zBashCompletionCache._outc             C   s   d}x,| j jj D ]}|jdk	r|jjrd}P qW tjj| j sF|ry~t	j
| jh}| jd |j }|jd |jd |jd | j jj j }dd	 |D }|jd
| |j  W dQ R X W n6 t	jk
r } z| jdt|  W Y dd}~X nX dS )z& Generate cache of available packages FNTzGenerating completion cache...z/create table if not exists available (pkg TEXT)zAcreate unique index if not exists pkg_available ON available(pkg)zdelete from availablec             S   s    g | ]}|j d krt|gqS )src)archstr).0xr   r   r   
<listcomp>@   s    z,BashCompletionCache.sack.<locals>.<listcomp>z*insert or ignore into available values (?)z Can't write completion cache: %s)r	   ZreposZiter_enabledZmetadatafreshospathexistsr
   sqlite3connectr   cursorexecutesackqueryZ	availableexecutemanycommitOperationalErrorr   )r   r   ZrepoconncurZ
avail_pkgsZavail_pkgs_inserter   r   r   r    (   s,    

zBashCompletionCache.sackc             C   s   | j s
dS ytj| jn}| jd |j }|jd |jd |jd tjj	| j
j j }dd |D }|jd| |j  W dQ R X W n6 tjk
r } z| jd	t|  W Y dd}~X nX dS )
z& Generate cache of installed packages NzGenerating completion cache...z/create table if not exists installed (pkg TEXT)zAcreate unique index if not exists pkg_installed ON installed(pkg)zdelete from installedc             S   s    g | ]}|j d krt|gqS )r   )r   r   )r   r   r   r   r   r   V   s    z3BashCompletionCache.transaction.<locals>.<listcomp>z*insert or ignore into installed values (?)z Can't write completion cache: %s)transactionr   r   r
   r   r   r   dnfr    Z_rpmdb_sackr	   r!   Z	installedr"   r#   r$   r   )r   r%   r&   Z	inst_pkgsZinst_pkgs_insertr'   r   r   r   r(   G   s"    


zBashCompletionCache.transaction)
__name__
__module____qualname__namer   staticmethodr   r    r(   __classcell__r   r   )r   r   r      s
   r   )Z
__future__r   r   Zdnf.i18nr   Zdnfpluginscorer   r)   Zos.pathr   r   ZPluginr   r   r   r   r   <module>   s   