meta_package_manager package

Submodules

meta_package_manager.base module

exception meta_package_manager.base.CLIError(code, output, error)[source]

Bases: exceptions.Exception

An error occured when running package manager CLI.

The exception internally keeps the result of CLI execution.

class meta_package_manager.base.PackageManager[source]

Bases: object

Base class from which all package manager definition should inherits.

cli_path = None
cli_args = []
platforms = frozenset([])
requirement = None
get_version()[source]

Invoke the manager and extract its own reported version.

version_string

Raw but cleaned string of the package manager version.

Returns None if the manager had an issue extracting its version.

version

Parsed and normalized package manager’s own version.

Returns an instance of packaging.Version or None.

id

Return package manager’s ID. Defaults based on class name.

This ID must be unique among all package manager definitions and lower-case as they’re used as feature flags for the mpm CLI.

name

Return package manager’s common name. Defaults based on class name.

supported

Is the package manager supported on that platform?

exists

Is the package manager CLI exist on the system?

executable

Is the package manager CLI can be executed by the current user?

fresh

Does the package manager match the version requirement?

available

Is the package manager available and ready-to-use on the system?

Returns True only if the main CLI:
1 - is supported on the current platform, 2 - exists on the system, 3 - is executable, and 4 - match the version requirement.
run(args, dry_run=False)[source]

Run a shell command, return the output and keep error message.

Removes ANSI escape codes, and returns ready-to-use strings.

sync()[source]

Fetch latest versions of installed packages.

installed

List packaages currently installed on the system.

Returns a list of dict with package ID, name and version.

outdated

List currently installed packages having a new version available.

Returns a list of dict with package ID, name, current installed version and latest upgradeable version.

upgrade_cli(package_id=None)[source]

Return a bash-compatible full-CLI to upgrade a package.

upgrade(package_id=None, dry_run=False)[source]

Perform the upgrade of the provided package to latest version.

upgrade_all_cli()[source]

Return a bash-compatible full-CLI to upgrade all packages.

upgrade_all(dry_run=False)[source]

Perform a full upgrade of all outdated packages to latest versions.

If the manager doesn’t implements a full upgrade one-liner, then fall-back to calling single-package upgrade one by one.

static render_cli(cmd, cli_format=u'plain')[source]

Return a formatted CLI in the provided format.

static render_bitbar_cli(full_cli)[source]

Format a bash-runnable full-CLI with parameters into bitbar schema.

meta_package_manager.cli module

meta_package_manager.cli.json(data)[source]

Utility function to render data structure into pretty printed JSON.

meta_package_manager.platform module

Helpers and utilities to handle platform idiosyncracies.

meta_package_manager.platform.is_linux()[source]

Return True only if current platform is Linux.

meta_package_manager.platform.is_macos()[source]

Return True only if current platform is macOS.

meta_package_manager.platform.is_windows()[source]

Return True only if current platform is Windows.

meta_package_manager.platform.current_os()[source]

Return ID and label of current OS.

meta_package_manager.platform.os_label(os_id)[source]

Return platform label for user-friendly output.

Module contents

Expose package-wide elements.