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

Note

This part of the documentation is created automatically.

class aptsources.sourceslist.Deb822SourceEntry(section: Optional[Union[Section, str]], file: str)
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.

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: Optional[bool]
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: Union[SourceEntry, Deb822SourceEntry]) bool
class aptsources.sourceslist.SourceEntry(line: str, file: Optional[str] = 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

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: Union[SourceEntry, Deb822SourceEntry]) 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: Optional[str] = None, architectures: Iterable[str] = []) Union[SourceEntry, Deb822SourceEntry]

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: Optional[str] = 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[Union[SourceEntry, Deb822SourceEntry]]) Tuple[List[Union[SourceEntry, Deb822SourceEntry]], Dict[Template, List[Union[SourceEntry, Deb822SourceEntry]]]]

get all parent and child channels in the sources list

load(file: str) None

(re)load the current sources

refresh() None

update the list of known entries

remove(source_entry: SourceEntry) 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