REDROOM
PHP 7.4.33
Path:
Logout
Edit File
Size: 3.86 KB
Close
/lib/python3.6/site-packages/dnf-plugins/generate_completion_cache.py
Text
Base64
# coding=utf-8 # generate_completion_cache.py - generate cache for dnf bash completion # Copyright © 2013 Elad Alfassa <elad@fedoraproject.org> # Copyright (C) 2014-2015 Igor Gnatenko <i.gnatenko.brain@gmail.com> # Copyright (C) 2015 Red Hat, Inc. # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions of # the GNU General Public License v.2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. You should have received a copy of the # GNU General Public License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. from __future__ import absolute_import from __future__ import unicode_literals from dnf.i18n import ucd from dnfpluginscore import logger import dnf import os.path import sqlite3 class BashCompletionCache(dnf.Plugin): name = 'generate_completion_cache' def __init__(self, base, cli): super(BashCompletionCache, self).__init__(base, cli) self.base = base self.cache_file = "/var/cache/dnf/packages.db" @staticmethod def _out(msg): logger.debug('Completion plugin: %s', msg) def sack(self): ''' Generate cache of available packages ''' # We generate this cache only if the repos were just freshed or if the # cache file doesn't exist fresh = False for repo in self.base.repos.iter_enabled(): if repo.metadata is not None and repo.metadata.fresh: # One fresh repo is enough to cause a regen of the cache fresh = True break if not os.path.exists(self.cache_file) or fresh: try: with sqlite3.connect(self.cache_file) as conn: self._out('Generating completion cache...') cur = conn.cursor() cur.execute( "create table if not exists available (pkg TEXT)") cur.execute( "create unique index if not exists " "pkg_available ON available(pkg)") cur.execute("delete from available") avail_pkgs = self.base.sack.query().available() avail_pkgs_insert = [[str(x)] for x in avail_pkgs if x.arch != "src"] cur.executemany("insert or ignore into available values (?)", avail_pkgs_insert) conn.commit() except sqlite3.OperationalError as e: self._out("Can't write completion cache: %s" % ucd(e)) def transaction(self): ''' Generate cache of installed packages ''' if not self.transaction: return try: with sqlite3.connect(self.cache_file) as conn: self._out('Generating completion cache...') cur = conn.cursor() cur.execute("create table if not exists installed (pkg TEXT)") cur.execute( "create unique index if not exists " "pkg_installed ON installed(pkg)") cur.execute("delete from installed") inst_pkgs = dnf.sack._rpmdb_sack(self.base).query().installed() inst_pkgs_insert = [[str(x)] for x in inst_pkgs if x.arch != "src"] cur.executemany("insert or ignore into installed values (?)", inst_pkgs_insert) conn.commit() except sqlite3.OperationalError as e: self._out("Can't write completion cache: %s" % ucd(e))
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 1 × Files: 17
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
__pycache__
DIR
-
drwxr-xr-x
2025-05-15 05:08:56
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
builddep.py
9.13 KB
lrw-r--r--
2024-04-08 10:02:45
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
changelog.py
4.85 KB
lrw-r--r--
2021-04-12 15:30:34
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
config_manager.py
10.63 KB
lrw-r--r--
2021-04-12 15:30:34
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
copr.py
29.59 KB
lrw-r--r--
2024-04-08 10:02:45
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
debug.py
12.27 KB
lrw-r--r--
2021-04-12 15:30:34
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
debuginfo-install.py
10.82 KB
lrw-r--r--
2021-04-12 15:30:34
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
download.py
12.04 KB
lrw-r--r--
2021-04-12 15:30:34
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
generate_completion_cache.py
3.86 KB
lrw-r--r--
2021-04-12 15:30:34
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
groups_manager.py
13.21 KB
lrw-r--r--
2024-04-08 10:02:45
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
needs_restarting.py
11.59 KB
lrw-r--r--
2024-04-08 10:02:46
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
repoclosure.py
6.65 KB
lrw-r--r--
2021-04-12 15:30:34
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
repodiff.py
11.21 KB
lrw-r--r--
2021-04-12 15:30:34
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
repograph.py
4.00 KB
lrw-r--r--
2021-04-12 15:30:34
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
repomanage.py
10.32 KB
lrw-r--r--
2024-04-08 10:02:45
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
reposync.py
14.30 KB
lrw-r--r--
2024-04-08 10:02:45
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
system_upgrade.py
26.17 KB
lrw-r--r--
2024-04-08 10:02:45
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
universal_hooks.py
5.78 KB
lrwxr-xr-x
2025-05-06 19:22:14
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).