pkgcheck.base module

Core classes and interfaces.

This defines a couple of standard feed types and scopes. Currently feed types are strings and scopes are integers, but you should use the symbolic names wherever possible (everywhere except for adding a new feed type) since this might change in the future. Scopes are integers, but do not rely on that either.

Feed types have to match exactly. Scopes are ordered: they define a minimally accepted scope.

class pkgcheck.base.Addon(options, **kwargs)[source]

Bases: object

Base class for extra functionality for pkgcheck other than a check.

The checkers can depend on one or more of these. They will get called at various points where they can extend pkgcheck (if any active checks depend on the addon).

These methods are not part of the checker interface because that would mean addon functionality shared by checkers would run twice. They are not plugins because they do not do anything useful if no checker depending on them is active.

This interface is not finished. Expect it to grow more methods (but if not overridden they will be no-ops).

Variables:

required_addons – sequence of addon dependencies

static mangle_argparser(parser)[source]

Add extra options and/or groups to the argparser.

This hook is always triggered, even if the checker is not activated (because it runs before the commandline is parsed).

Parameters:

parser – an C{argparse.ArgumentParser} instance.

required_addons = ()
class pkgcheck.base.ConditionalScope(desc: str, level: int = -99, _children: tuple = ())[source]

Bases: Scope

Scope for checks run only in certain circumstances.

level: int = -99
class pkgcheck.base.LocationScope(desc: str, level: int = 0, _children: tuple = ())[source]

Bases: Scope

Scope for location-specific checks.

level: int = 0
class pkgcheck.base.LogMap(func: str, call: Callable)[source]

Bases: object

Log function to callable mapping.

call: Callable
func: str
pkgcheck.base.LogReports(*logmaps)[source]

Context manager for turning log messages into results.

class pkgcheck.base.PackageScope(desc: str, level: int, _children: tuple = ())[source]

Bases: Scope

Scope for package-specific checks.

exception pkgcheck.base.PkgcheckException[source]

Bases: Exception

Generic pkgcheck exception.

exception pkgcheck.base.PkgcheckUserException(msg, verbosity=None)[source]

Bases: PkgcheckException, UserException

Generic pkgcheck exception for user-facing cli output..

class pkgcheck.base.ProgressManager(verbosity=0)[source]

Bases: AbstractContextManager

Context manager for handling progressive output.

Useful for updating the user about the status of a long running process.

class pkgcheck.base.Scope(desc: str, level: int, _children: tuple = ())[source]

Bases: object

Generic scope for scans, checks, and results.

desc: str
level: int
pkgcheck.base.get_addons(objects)[source]

Return tuple of addons for a given sequence of objects.

pkgcheck.base.param_name(cls)[source]

Restructure class names for injected parameters.

For example, GitAddon -> git_addon and GitCache -> git_cache.