kojismokydingo.sift.builds

Koji Smoky Dingo - Sifty Dingo filtering for Koji Builds

This module provides sieves for filtering through koji build info dicts.

author:

Christopher O'Brien <obriencj@gmail.com>

license:

GPL v3

class CGImportedSieve(sifter, *tokens)[source]

Bases: MatcherSieve

usage: (cg-imported [CGNAME...])

Passes build infos that have been produced via a cg-import by any of the named content generators. If no CGs are named, then passes build infos that have been produced by any content generator.

check(session, binfo)[source]

Override to return True if the predicate matches the given info dict.

This is used by the default run implementation in a filter. Only the info dicts which return True from this method will be included in the results.

Parameters:

info -- The info dict to be checked.

name = 'cg-imported'
prep(session, binfos)[source]

Override if some bulk pre-loading operations are necessary.

This is used by the default run implementation to allow bulk operations to be performed over the entire set of info dicts to be filtered, rather than one at a time in the check method

class CompareLatestIDSieve(sifter, comparison, tag)[source]

Bases: CompareLatestSieve

usage: `(compare-latest-id OP TAG)`

Filters for builds which have an ID which compares against the latest build of the same package from TAG.

Valid comparison ops are:

  • ==

  • !=

  • >

  • >=

  • <

  • <=

example: `(compare-latest-id >= foo-1.0-released)` will filter for builds which have an ID that is greater-than-or-equal-to the ID of the latest build of the same package name in the foo-1.0-released tag.

check(session, binfo)[source]

Override to return True if the predicate matches the given info dict.

This is used by the default run implementation in a filter. Only the info dicts which return True from this method will be included in the results.

Parameters:

info -- The info dict to be checked.

comparison_key = operator.itemgetter('id')
name = 'compare-latest-id'
class CompareLatestNVRSieve(sifter, comparison, tag)[source]

Bases: CompareLatestSieve

usage: `(compare-latest-nvr OP TAG)`

Filters for builds which have an NVR which compares against the latest build of the same package from TAG.

Valid comparison ops are:

  • ==

  • !=

  • >

  • >=

  • <

  • <=

example: `(compare-latest-nvr >= foo-1.0-released)` will filter for builds which have an NVR that is greater-than-or-equal-to the NVR of the latest build of the same package name in the foo-1.0-released tag.

check(session, binfo)[source]

Override to return True if the predicate matches the given info dict.

This is used by the default run implementation in a filter. Only the info dicts which return True from this method will be included in the results.

Parameters:

info -- The info dict to be checked.

comparison_key

alias of BuildNEVRCompare

name = 'compare-latest-nvr'
class EVRCompareEQ(sifter, version)[source]

Bases: EVRCompare

Usage: (== VER)

VER can be in any of the following forms

  • EPOCH:VERSION

  • EPOCH:VERSION-RELEASE

  • VERSION

  • VERSION-RELEASE

If EPOCH is omitted, it is presumed to be 0. If RELEASE is omitted, it is presumed to be equivalent.

Passes builds whose EVR compares as requested.

name = '=='
class EVRCompareGE(sifter, version)[source]

Bases: EVRCompare

Usage: (>= VER)

VER can be in any of the following forms

  • EPOCH:VERSION

  • EPOCH:VERSION-RELEASE

  • VERSION

  • VERSION-RELEASE

If EPOCH is omitted, it is presumed to be 0. If RELEASE is omitted, it is presumed to be equivalent.

Passes builds whose EVR compares as requested.

name = '>='
class EVRCompareGT(sifter, version)[source]

Bases: EVRCompare

Usage: (> VER)

VER can be in any of the following forms

  • EPOCH:VERSION

  • EPOCH:VERSION-RELEASE

  • VERSION

  • VERSION-RELEASE

If EPOCH is omitted, it is presumed to be 0. If RELEASE is omitted, it is presumed to be equivalent.

Passes builds whose EVR compares as requested.

name = '>'
class EVRCompareLE(sifter, version)[source]

Bases: EVRCompare

Usage: (<= VER)

VER can be in any of the following forms

  • EPOCH:VERSION

  • EPOCH:VERSION-RELEASE

  • VERSION

  • VERSION-RELEASE

If EPOCH is omitted, it is presumed to be 0. If RELEASE is omitted, it is presumed to be equivalent.

Passes builds whose EVR compares as requested.

name = '<='
class EVRCompareLT(sifter, version)[source]

Bases: EVRCompare

Usage: (< VER)

VER can be in any of the following forms

  • EPOCH:VERSION

  • EPOCH:VERSION-RELEASE

  • VERSION

  • VERSION-RELEASE

If EPOCH is omitted, it is presumed to be 0. If RELEASE is omitted, it is presumed to be equivalent.

Passes builds whose EVR compares as requested.

name = '<'
class EVRCompareNE(sifter, version)[source]

Bases: EVRCompare

Usage: (!= VER)

VER can be in any of the following forms

  • EPOCH:VERSION

  • EPOCH:VERSION-RELEASE

  • VERSION

  • VERSION-RELEASE

If EPOCH is omitted, it is presumed to be 0. If RELEASE is omitted, it is presumed to be equivalent.

Passes builds whose EVR compares as requested.

name = '!='
class EVRHigh(sifter, count=1)[source]

Bases: EVRSorted

usage: (evr-high [count: COUNT])

Filters to only the builds which are the higest EVR of their given package name.

COUNT if specified is the number of highest EVR builds to return. Default is 1

name = 'evr-high'
class EVRLow(sifter, count=1)[source]

Bases: EVRSorted

usage: (evr-low [count: COUNT])

Filters to only the builds which are the lowest EVR of their given package name.

COUNT if specified is the number of lowest EVR builds to return. Default is 1

name = 'evr-low'
class EpochSieve(sifter, *exprs)[source]

Bases: ItemSieve

Usage: (epoch EPOCH [EPOCH...])

filters for dict infos whose epoch key matches any of the given EPOCH matchers.

field = 'epoch'
name = 'epoch'
class ImportedSieve(sifter, *tokens, **options)[source]

Bases: Sieve

Usage: (imported)

filters for build info dicts whose task ID is empty or null.

Parameters:

sifter (Sifter)

check(session, binfo)[source]

Override to return True if the predicate matches the given info dict.

This is used by the default run implementation in a filter. Only the info dicts which return True from this method will be included in the results.

Parameters:

info -- The info dict to be checked.

name = 'imported'
class InheritedSieve(sifter, tagname, *tagnames)[source]

Bases: IntStrSieve

usage: (inherited TAG [TAG...])

Matches builds which are tagged into any of the given tags or their parent tags. Each TAG must be a tag name or tag ID, patterns are not allowed.

check(session, binfo)[source]

Override to return True if the predicate matches the given info dict.

This is used by the default run implementation in a filter. Only the info dicts which return True from this method will be included in the results.

Parameters:

info -- The info dict to be checked.

get_info_cache(binfo)[source]

Gets a cache dict from the sifter using the name of this sieve and the sifter's designated key for the given info dict. The default sifter key will get the "id" value from the info dict.

The same cache dict will be returned for this info dict until the sifter has its reset method invoked.

name = 'inherited'
prep(session, binfos)[source]

Override if some bulk pre-loading operations are necessary.

This is used by the default run implementation to allow bulk operations to be performed over the entire set of info dicts to be filtered, rather than one at a time in the check method

class LatestMavenSieve(sifter, tagname, *tagnames)[source]

Bases: IntStrSieve, CacheMixin

usage: (latest-maven TAG [TAG...])

Passes build infos that have btype maven and are the build of their GAV in any of the tags.

check(session, binfo)[source]

Override to return True if the predicate matches the given info dict.

This is used by the default run implementation in a filter. Only the info dicts which return True from this method will be included in the results.

Parameters:

info -- The info dict to be checked.

name = 'latest-maven'
prep(session, binfos)[source]

Override if some bulk pre-loading operations are necessary.

This is used by the default run implementation to allow bulk operations to be performed over the entire set of info dicts to be filtered, rather than one at a time in the check method

class LatestSieve(sifter, tagname, *tagnames)[source]

Bases: IntStrSieve, CacheMixin

usage: (latest TAG [TAG...])

Passes build infos that are the latest build of their package name in any of the tags.

check(session, binfo)[source]

Override to return True if the predicate matches the given info dict.

This is used by the default run implementation in a filter. Only the info dicts which return True from this method will be included in the results.

Parameters:

info -- The info dict to be checked.

name = 'latest'
prep(session, binfos)[source]

Override if some bulk pre-loading operations are necessary.

This is used by the default run implementation to allow bulk operations to be performed over the entire set of info dicts to be filtered, rather than one at a time in the check method

class NVRSieve(sifter, *exprs)[source]

Bases: ItemSieve

Usage: (nvr NVR [NVR...])

filters for dict infos whose nvr key matches any of the given NVR matchers.

field = 'nvr'
name = 'nvr'
class NameSieve(sifter, *exprs)[source]

Bases: ItemSieve

Usage: (name NAME [NAME...])

filters for dict infos whose name key matches any of the given NAME matchers.

field = 'name'
name = 'name'
class OwnerSieve(sifter, user, *users)[source]

Bases: IntStrSieve

Usage: (owner USER [USER...])`

filters for builds whose owner_name or owner_id key matches any of the given USERs.

The users will be validated at the time of the sieve's first invocation, which may result in a NoSuchUser error.

check(session, binfo)[source]

Override to return True if the predicate matches the given info dict.

This is used by the default run implementation in a filter. Only the info dicts which return True from this method will be included in the results.

Parameters:

info -- The info dict to be checked.

name = 'owner'
prep(session, _build_infos)[source]

Override if some bulk pre-loading operations are necessary.

This is used by the default run implementation to allow bulk operations to be performed over the entire set of info dicts to be filtered, rather than one at a time in the check method

class PkgAllowedSieve(sifter, tagname, *tagnames)[source]

Bases: PkgListSieve

usage: (pkg-allowed TAG [TAG...])

Matches builds which are have their package listing present and not blocked in any of the given tags or their parents.

check(session, binfo)[source]

Override to return True if the predicate matches the given info dict.

This is used by the default run implementation in a filter. Only the info dicts which return True from this method will be included in the results.

Parameters:

info -- The info dict to be checked.

name = 'pkg-allowed'
class PkgBlockedSieve(sifter, tagname, *tagnames)[source]

Bases: PkgListSieve

usage: (pkg-blocked TAG [TAG...])

Matches builds which are have their package name blocked in any of the given tags or their parents.

check(session, binfo)[source]

Override to return True if the predicate matches the given info dict.

This is used by the default run implementation in a filter. Only the info dicts which return True from this method will be included in the results.

Parameters:

info -- The info dict to be checked.

name = 'pkg-blocked'
class PkgUnlistedSieve(sifter, tagname, *tagnames)[source]

Bases: PkgListSieve

usage: (pkg-unlisted TAG [TAG...])

Matches builds which have their package name unlisted (neither allowed nor blocked) in any of the given tags or their parents.

check(session, binfo)[source]

Override to return True if the predicate matches the given info dict.

This is used by the default run implementation in a filter. Only the info dicts which return True from this method will be included in the results.

Parameters:

info -- The info dict to be checked.

name = 'pkg-unlisted'
class ReleaseSieve(sifter, *exprs)[source]

Bases: ItemSieve

Usage: (release REL [REL...])

filters for dict infos whose release key matches any of the given REL matchers.

field = 'release'
name = 'release'
class SignedSieve(sifter, *tokens)[source]

Bases: MatcherSieve

usage: (signed [KEY...])

Passes builds which have RPMs signed with any of the given keys. If no keys are specified then passes builds which have RPMs signed with any key at all.

check(session, binfo)[source]

Override to return True if the predicate matches the given info dict.

This is used by the default run implementation in a filter. Only the info dicts which return True from this method will be included in the results.

Parameters:

info -- The info dict to be checked.

name = 'signed'
prep(session, binfos)[source]

Override if some bulk pre-loading operations are necessary.

This is used by the default run implementation to allow bulk operations to be performed over the entire set of info dicts to be filtered, rather than one at a time in the check method

class StateSieve(sifter, name, *names)[source]

Bases: Sieve

Usage: (state BUILD_STATE [BUILD_STATE...])

filters for dict infos whose state key matches any of the given koji build states. Build states may be specified as either an integer or one of the following strings or symbols

  • BUILDING

  • COMPLETE

  • DELETED

  • FAILED

  • CANCELED

check(session, info)[source]

Override to return True if the predicate matches the given info dict.

This is used by the default run implementation in a filter. Only the info dicts which return True from this method will be included in the results.

Parameters:

info -- The info dict to be checked.

name = 'state'
class TaggedSieve(sifter, *tokens)[source]

Bases: MatcherSieve

usage: (tagged [TAG...])

If no TAG patterns are specified, matches builds which have any tags at all.

If TAG patterns are specified, then only matches builds which have a tag that matches any of the given patterns.

check(session, binfo)[source]

Override to return True if the predicate matches the given info dict.

This is used by the default run implementation in a filter. Only the info dicts which return True from this method will be included in the results.

Parameters:

info -- The info dict to be checked.

name = 'tagged'
prep(session, binfos)[source]

Override if some bulk pre-loading operations are necessary.

This is used by the default run implementation to allow bulk operations to be performed over the entire set of info dicts to be filtered, rather than one at a time in the check method

class TypeSieve(sifter, btype, *btypes)[source]

Bases: MatcherSieve

usage: (type BTYPE [BTYPE...])

Passes build infos that have archives of the given btype. Normal btypes are rpm, maven, image, and win.

check(session, binfo)[source]

Override to return True if the predicate matches the given info dict.

This is used by the default run implementation in a filter. Only the info dicts which return True from this method will be included in the results.

Parameters:

info -- The info dict to be checked.

name = 'type'
prep(session, binfos)[source]

Override if some bulk pre-loading operations are necessary.

This is used by the default run implementation to allow bulk operations to be performed over the entire set of info dicts to be filtered, rather than one at a time in the check method

class VersionSieve(sifter, *exprs)[source]

Bases: ItemSieve

Usage: (version VER [VER...])

filters for dict infos whose version key matches any of the given VER matchers.

field = 'version'
name = 'version'
build_info_sieves()[source]

A new list containing the default build-info sieve classes.

This function is used by build_info_sifter when creating its Sifter instance.

Return type:

List[Type[Sieve]]

build_info_sifter(source, params=None)[source]

Create a Sifter from the source using the default build-info Sieves.

Parameters:
  • source (str) -- sieve expressions source

  • params (Dict[str, str] | None) -- sieve parameters

Return type:

Sifter

sift_builds(session, src_str, build_infos, params=None)[source]

Filter a group of build infos with a sieve compiled from the given source string.

Parameters:
  • session (ClientSession) -- an active koji client session

  • src_str (str) -- sieve expressions source

  • build_infos (Iterable[BuildInfo]) -- list of build info dicts to filter

  • params (Dict[str, str] | None) -- sieve parameters

Returns:

mapping of flags to matching build info dicts

Return type:

Dict[str, List[BuildInfo]]

sift_nvrs(session, src_str, nvrs, params=None)[source]

Load a group of NVRs as build infos and filter them with a sieve compiled from the given source string.

Parameters:
  • session (ClientSession) -- an active koji client session

  • src_str (str) -- sieve expressions source

  • nvrs (Iterable[str | int]) -- list of NVRs to load and filter

  • params (Dict[str, str] | None) -- sieve parameters

Returns:

mapping of flags to matching build info dicts

Return type:

Dict[str, List[BuildInfo]]