pkgcore.bugzilla.pkglist module

Parsing and rewriting of the cf_stabilisation_atoms bug field.

The field is a newline separated list of <package spec> [keyword...] lines, with # comments and three keyword sentinels: * expands to the keywords suggested for that package, ^ repeats the previous line’s keywords, and - marks a line as deliberately having none.

PackageList keeps the original text and rewrites only the lines it has to, so indentation and comments on untouched lines survive a round trip.

class pkgcore.bugzilla.pkglist.PackageList(text: str = '', *, bug_id: BugId | None = None)[source]

Bases: Simple

A lazily parsed view of a bug’s package list.

Parsing is deferred so fetching a bug with a malformed list never fails; only code that looks at the list does.

property atoms: tuple[atom, ...]
bug_id
classmethod build(entries: Iterable[tuple[atom, Iterable[str]]]) PackageList[source]

Construct a fresh list from atoms and their keywords

entries

Every line of the list, blanks and comments included

expand(suggest: Callable[[atom], Sequence[str]]) PackageList[source]

Resolve the * and ^ sentinels.

Only the lines that change are rewritten, and each keeps everything but its keywords, so the result can go straight back onto the bug.

Parameters:

suggest – returns the keywords a package should be requested for, in the order they should be written; returning nothing collapses the line to -. Which version to suggest for is the caller’s to decide

Returns:

the expanded list, or self if nothing needed rewriting

Raises:

PackageListError – on a ^ with nothing above it to copy, or one that would copy nothing onto a line asking for keywords

keywords_for(pkg: atom) tuple[str, ...][source]

Keywords requested for an atom, as written

text
class pkgcore.bugzilla.pkglist.PackageListEntry(lineno: int, raw: str, pkg: atom | None, keywords: tuple[str, ...] = (), comment: str = '', eol: str = '')[source]

Bases: object

A single line of a package list

comment: str
eol: str
property is_blank: bool
keywords: tuple[str, ...]
lineno: int
pkg: atom | None
raw: str
with_keywords(keywords: Iterable[str]) PackageListEntry[source]

Return a copy with new keywords, rewriting only the keyword text.

The rest of the line survives as written: the spec in its original spelling, the alignment around it, and the comment.

Parameters:

keywords – the keywords to write in place of the current ones

Returns:

the rewritten entry, or self if the line holds no spec

pkgcore.bugzilla.pkglist.parse_atom(token: str) atom[source]

Parse a package list token into an atom.

Stabilization lines carry a bare cat/pkg-1.2.3 rather than the =cat/pkg-1.2.3 an atom needs, so the versioned form is tried first.

A package list names packages to act on, so the qualifiers that would make that ambiguous are rejected: blockers, use deps, slot operators and repo ids all mean something the list has no way to honour.

Parameters:

token – the first whitespace separated field of a list line

Returns:

the atom the token names

Raises:

MalformedAtom – if the token isn’t a usable package spec