aptsources.sourceslist — Provide an abstraction of the sources.list


This part of the documentation is created automatically.

class aptsources.sourceslist.Deb822SourceEntry(section: Section | str | None, file: str, list: SourcesList | None = None)
property architectures

The list of architectures

property comment: str

Legacy attribute describing the paragraph header.

property comps

Components in the source

property disabled: bool

Check if Enabled: no is set.

property dist

Suites in the source

property invalid: bool

A section is invalid if it doesn’t have proper entries.

property line: str

The entire (original) paragraph.

merge(other: SourceEntry | Deb822SourceEntry) bool

Merge the two entries if they are compatible.

set_enabled(enabled: bool) None

Deprecated (for deb822) accessor for .disabled

str() str

Section as a string, newline terminated.

property suites

Suites in the source

property trusted: bool | None

Return the value of the Trusted field

property type

The list of types

property types

The list of types

property uri

URIs in the source

property uris

URIs in the source

class aptsources.sourceslist.NullMatcher

a Matcher that does nothing

match(s: SourceEntry | Deb822SourceEntry | ExplodedDeb822SourceEntry) bool
class aptsources.sourceslist.SourceEntry(line: str, file: str | None = None)

single sources.list entry

static mysplit(line: str) list[str]

a split() implementation that understands the sources.list format better and takes [] into account (for e.g. cdroms)

parse(line: str) None

parse a given sources.list (textual) line and break it up into the field we have

set_enabled(new_value: bool) None

set a line to enabled or disabled

str() str

return the current line as string

property suites: list[str]

deb822 compatible accessor for the suite

property types: list[str]

deb822 compatible accessor for the type

property uris: list[str]

deb822 compatible accessor for the uri

class aptsources.sourceslist.SourceEntryMatcher(matcherPath: str)

matcher class to make a source entry look nice lots of predefined matchers to make it i18n/gettext friendly

match(source: SourceEntry | Deb822SourceEntry | ExplodedDeb822SourceEntry) bool

Add a matching template to the source

class aptsources.sourceslist.SourcesList(withMatcher: bool = True, matcherPath: str = '/usr/share/python-apt/templates/', *, deb822: bool = False)

represents the full sources.list + sources.list.d file

add(type: str, uri: str, dist: str, orig_comps: list[str], comment: str = '', pos: int = -1, file: str | None = None, architectures: Iterable[str] = [], parent: SourceEntry | Deb822SourceEntry | ExplodedDeb822SourceEntry | None = None) SourceEntry | Deb822SourceEntry | ExplodedDeb822SourceEntry

Add a new source to the sources.list. The method will search for existing matching repos and will try to reuse them as far as possible

backup(backup_ext: str | None = None) str

make a backup of the current source files, if no backup extension is given, the current date/time is used (and returned)

check_for_relations(sources_list: Iterable[SourceEntry | Deb822SourceEntry]) tuple[list[SourceEntry | Deb822SourceEntry], dict[Template, list[SourceEntry | Deb822SourceEntry]]]

get all parent and child channels in the sources list

exploded_list() list[SourceEntry | Deb822SourceEntry | ExplodedDeb822SourceEntry]

Present an exploded view of the list where each entry corresponds exactly to a Release file.

A release file is uniquely identified by the triplet (type, uri, suite). Old style entries always referred to a single release file, but deb822 entries allow multiple values for each of those fields.

index(entry: SourceEntry | Deb822SourceEntry | ExplodedDeb822SourceEntry) int
load(file: str) None

(re)load the current sources

merge() None

Merge consecutive entries that have been split back together.

refresh() None

update the list of known entries

remove(source_entry: SourceEntry | Deb822SourceEntry | ExplodedDeb822SourceEntry) None

remove the specified entry from the sources.list

restore_backup(backup_ext: str) None

restore sources.list files based on the backup extension

save() None

save the current sources

aptsources.sourceslist.is_mirror(master_uri: str, compare_uri: str) bool

check if the given add_url is idential or a mirror of orig_uri e.g.: master_uri = archive.ubuntu.com compare_uri = de.archive.ubuntu.com -> True