Markdown Format | JSON API | MCP Server Tool
Help on package apt: NAME apt - High-Level Interface for working with apt. PACKAGE CONTENTS auth cache cdrom debfile package progress (package) utils CLASSES apt_pkg.Cdrom(builtins.object) apt.cdrom.Cdrom builtins.object apt.cache.Cache apt.package.Package class Cache(builtins.object) | Cache(progress=None, rootdir=None, memonly=False) | | Dictionary-like package cache. | | The APT cache file contains a hash table mapping names of binary | packages to their metadata. A Cache object is the in-core | representation of the same. It provides access to APTs idea of the | list of available packages. | | The cache can be used like a mapping from package names to Package | objects (although only getting items is supported). | | Keyword arguments: | progress -- a OpProgress object, | rootdir -- an alternative root directory. if that is given the system | sources.list and system lists/files are not read, only file relative | to the given rootdir, | memonly -- build the cache in memory only. | | | .. versionchanged:: 1.0 | | The cache now supports package names with special architecture | qualifiers such as :all and :native. It does not export them | in :meth:`keys()`, though, to keep :meth:`keys()` a unique set. | | Methods defined here: | | __contains__(self, key) | | __enter__(self) | Enter the with statement | | __exit__(self, exc_type, exc_value, traceback) | Exit the with statement | | __getitem__(self, key) | look like a dictionary (get key) | | __init__(self, progress=None, rootdir=None, memonly=False) | Initialize self. See help(type(self)) for accurate signature. | | __iter__(self) | | __len__(self) | | actiongroup(self) | Return an `ActionGroup` object for the current cache. | | Action groups can be used to speedup actions. The action group is | active as soon as it is created, and disabled when the object is | deleted or when release() is called. | | You can use the action group as a context manager, this is the | recommended way:: | | with cache.actiongroup(): | for package in my_selected_packages: | package.mark_install() | | This way, the action group is automatically released as soon as the | with statement block is left. It also has the benefit of making it | clear which parts of the code run with a action group and which | don't. | | cache_post_change(self) | called internally if the cache has changed, emit a signal then | | cache_pre_change(self) | called internally if the cache is about to change, emit | a signal then | | clear(self) | Unmark all changes | | close(self) | Close the package cache | | commit(self, fetch_progress=None, install_progress=None, allow_unauthenticated=None) | Apply the marked changes to the cache. | | The first parameter, *fetch_progress*, refers to a FetchProgress() | object as found in apt.progress, the default being | apt.progress.FetchProgress(). | | The second parameter, *install_progress*, is a | apt.progress.InstallProgress() object. | | The keyword-only parameter *allow_unauthenticated* specifies whether | to allow unauthenticated downloads. If not specified, it defaults to | the configuration option `APT::Get::AllowUnauthenticated`. | | connect(self, name, callback) | Connect to a signal. | | .. deprecated:: 1.0 | | Please use connect2() instead, as this function is very | likely to cause a memory leak. | | connect2(self, name, callback, *args, **kwds) | Connect to a signal. | | The callback will be passed the cache as an argument, and | any arguments passed to this function. Make sure that, if you | pass a method of a class as your callback, your class does not | contain a reference to the cache. | | Cyclic references to the cache can cause issues if the Cache object | is replaced by a new one, because the cache keeps a lot of objects and | tens of open file descriptors. | | currently only used for cache_{post,pre}_{changed,open}. | | .. versionadded:: 1.0 | | fetch_archives(self, progress=None, fetcher=None, allow_unauthenticated=None) | Fetch the archives for all packages marked for install/upgrade. | | You can specify either an :class:`apt.progress.base.AcquireProgress()` | object for the parameter *progress*, or specify an already | existing :class:`apt_pkg.Acquire` object for the parameter *fetcher*. | | The return value of the function is undefined. If an error occurred, | an exception of type :class:`FetchFailedException` or | :class:`FetchCancelledException` is raised. | | The keyword-only parameter *allow_unauthenticated* specifies whether | to allow unauthenticated downloads. If not specified, it defaults to | the configuration option `APT::Get::AllowUnauthenticated`. | | .. versionadded:: 0.8.0 | | fix_broken(self) | Fix broken packages. | | get(self, key, default=None) | Return *self*[*key*] or *default* if *key* not in *self*. | | .. versionadded:: 1.1 | | get_changes(self) | Get the marked changes | | get_providing_packages(self, pkgname, candidate_only=True, include_nonvirtual=False) | Return a list of all packages providing a package. | | Return a list of packages which provide the virtual package of the | specified name. | | If 'candidate_only' is False, return all packages with at | least one version providing the virtual package. Otherwise, | return only those packages where the candidate version | provides the virtual package. | | If 'include_nonvirtual' is True then it will search for all | packages providing pkgname, even if pkgname is not itself | a virtual pkg. | | has_key(self, key) | | install_archives(self, pm, install_progress) | The first parameter *pm* refers to an object returned by | apt_pkg.PackageManager(). | | The second parameter *install_progress* refers to an InstallProgress() | object of the module apt.progress. | | This releases a system lock in newer versions, if there is any, | and reestablishes it afterwards. | | is_virtual_package(self, pkgname) | Return whether the package is a virtual package. | | keys(self) | | open(self, progress=None) | Open the package cache, after that it can be used like | a dictionary | | update(self, fetch_progress=None, pulse_interval=0, raise_on_error=True, sources_list=None) | Run the equivalent of apt-get update. | | You probably want to call open() afterwards, in order to utilise the | new cache. Otherwise, the old cache will be used which can lead to | strange bugs. | | The first parameter *fetch_progress* may be set to an instance of | apt.progress.FetchProgress, the default is apt.progress.FetchProgress() | . | sources_list -- Update a alternative sources.list than the default. | Note that the sources.list.d directory is ignored in this case | | upgrade(self, dist_upgrade=False) | Upgrade all packages. | | If the parameter *dist_upgrade* is True, new dependencies will be | installed as well (and conflicting packages may be removed). The | default value is False. | | ---------------------------------------------------------------------- | Readonly properties defined here: | | broken_count | Return the number of packages with broken dependencies. | | delete_count | Return the number of packages marked for deletion. | | dpkg_journal_dirty | Return True if the dpkg was interrupted | | All dpkg operations will fail until this is fixed, the action to | fix the system if dpkg got interrupted is to run | 'dpkg --configure -a' as root. | | install_count | Return the number of packages marked for installation. | | keep_count | Return the number of packages marked as keep. | | req_reinstall_pkgs | Return the packages not downloadable packages in reqreinst state. | | required_download | Get the size of the packages that are required to download. | | required_space | Get the size of the additional required space on the fs. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class Cdrom(apt_pkg.Cdrom) | Cdrom(progress=None, mountpoint=None, nomount=True) | | Support for apt-cdrom like features. | | This class has several optional parameters for initialisation, which may | be used to influence the behaviour of the object: | | The optional parameter `progress` is a CdromProgress() subclass, which will | ask for the correct cdrom, etc. If not specified or None, a CdromProgress() | object will be used. | | The optional parameter `mountpoint` may be used to specify an alternative | mountpoint. | | If the optional parameter `nomount` is True, the cdroms will not be | mounted. This is the default behaviour. | | Method resolution order: | Cdrom | apt_pkg.Cdrom | builtins.object | | Methods defined here: | | __init__(self, progress=None, mountpoint=None, nomount=True) | Initialize self. See help(type(self)) for accurate signature. | | add(self, progress=None) | Add cdrom to the sources.list. | | ident(self, progress=None) | Identify the cdrom. | | ---------------------------------------------------------------------- | Readonly properties defined here: | | in_sources_list | Check if the cdrom is already in the current sources.list. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Static methods inherited from apt_pkg.Cdrom: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. class Package(builtins.object) | Package(pcache, pkgiter) | | Representation of a package in a cache. | | This class provides methods and properties for working with a package. It | lets you mark the package for installation, check if it is installed, and | much more. | | Methods defined here: | | __init__(self, pcache, pkgiter) | Init the Package object | | __lt__(self, other) | Return self<value. | | __repr__(self) | Return repr(self). | | __str__(self) | Return str(self). | | architecture(self) | Return the Architecture of the package. | | Note that for Architecture: all packages, this returns the | native architecture, as they are internally treated like native | packages. To get the concrete architecture, look at the | :attr:`Version.architecture` attribute. | | .. versionchanged:: 0.7.100.3 | This is now the package's architecture in the multi-arch sense, | previously it was the architecture of the candidate version | and deprecated. | | commit(self, fprogress, iprogress) | Commit the changes. | | The parameter *fprogress* refers to a apt_pkg.AcquireProgress() object, | like apt.progress.text.AcquireProgress(). | | The parameter *iprogress* refers to an InstallProgress() object, as | found in apt.progress.base. | | get_changelog(self, uri=None, cancel_lock=None) | Download the changelog of the package and return it as unicode | string. | | The parameter *uri* refers to the uri of the changelog file. It may | contain multiple named variables which will be substitued. These | variables are (src_section, prefix, src_pkg, src_ver). An example is | the Ubuntu changelog:: | | "http://changelogs.ubuntu.com/changelogs/pool" \ | "/%(src_section)s/%(prefix)s/%(src_pkg)s" \ | "/%(src_pkg)s_%(src_ver)s/changelog" | | The parameter *cancel_lock* refers to an instance of threading.Event, | which if set, prevents the download. | | mark_auto(self, auto=True) | Mark a package as automatically installed. | | Call this function to mark a package as automatically installed. If the | optional parameter *auto* is set to ``False``, the package will not be | marked as automatically installed anymore. The default is ``True``. | | mark_delete(self, auto_fix=True, purge=False) | Mark a package for deletion. | | If *auto_fix* is ``True``, the resolver will be run, trying to fix | broken packages. This is the default. | | If *purge* is ``True``, remove the configuration files of the package | as well. The default is to keep the configuration. | | mark_install(self, auto_fix=True, auto_inst=True, from_user=True) | Mark a package for install. | | If *autoFix* is ``True``, the resolver will be run, trying to fix | broken packages. This is the default. | | If *autoInst* is ``True``, the dependencies of the packages will be | installed automatically. This is the default. | | If *fromUser* is ``True``, this package will not be marked as | automatically installed. This is the default. Set it to False if you | want to be able to automatically remove the package at a later stage | when no other package depends on it. | | mark_keep(self) | Mark a package for keep. | | mark_upgrade(self, from_user=True) | Mark a package for upgrade. | | ---------------------------------------------------------------------- | Readonly properties defined here: | | essential | Return True if the package is an essential part of the system. | | fullname | Return the name of the package, including architecture. | | Note that as for :meth:`architecture`, this returns the | native architecture for Architecture: all packages. | | .. versionadded:: 0.7.100.3 | | has_config_files | Checks whether the package is is the config-files state. | | id | Return a uniq ID for the package. | | This can be used eg. to store additional information about the pkg. | | installed | Return the currently installed version of the package. | | .. versionadded:: 0.7.9 | | installed_files | Return a list of files installed by the package. | | Return a list of unicode names of the files which have | been installed by this package | | is_auto_installed | Return whether the package is marked as automatically installed. | | is_auto_removable | Return ``True`` if the package is no longer required. | | If the package has been installed automatically as a dependency of | another package, and if no packages depend on it anymore, the package | is no longer required. | | is_inst_broken | Return True if the to-be-installed package is broken. | | is_installed | Return ``True`` if the package is installed. | | is_now_broken | Return True if the installed package is broken. | | is_upgradable | Return ``True`` if the package is upgradable. | | marked_delete | Return ``True`` if the package is marked for delete. | | marked_downgrade | Package is marked for downgrade | | marked_install | Return ``True`` if the package is marked for install. | | marked_keep | Return ``True`` if the package is marked for keep. | | marked_reinstall | Return ``True`` if the package is marked for reinstall. | | marked_upgrade | Return ``True`` if the package is marked for upgrade. | | name | Return the name of the package, possibly including architecture. | | If the package is not part of the system's preferred architecture, | return the same as :attr:`fullname`, otherwise return the same | as :attr:`shortname` | | .. versionchanged:: 0.7.100.3 | | As part of multi-arch, this field now may include architecture | information. | | shortname | Return the name of the package, without architecture. | | .. versionadded:: 0.7.100.3 | | versions | Return a VersionList() object for all available versions. | | .. versionadded:: 0.7.9 | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | candidate | Return the candidate version of the package. | | This property is writeable to allow you to set the candidate version | of the package. Just assign a Version() object, and it will be set as | the candidate version. DATA __all__ = ['Cache', 'Cdrom', 'Package'] FILE /usr/lib/python3/dist-packages/apt/__init__.py
Generated by phpMan Author: Che Dong Under GNU General Public License
2026-06-02 05:14 @216.73.216.198 CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)