The Source object is the base class for all of the sources used within RepoLib. The Source class itself is a subclass of the deb822() class from the Python Debian module, which provides a dict-like interface for setting data as well as several methods for dumping data to files and other helpful functions.
- class repolib.Source (file=None)
Create a new Source object.
The Source object has the following attributes:
- ident - The system-identifier to use for this source.
- name - The human-readable name of the source. (default: ‘’)
- enabled - Whether the source is enabled or not at creation. (default: True)
- types - A list of the types that the source should use. (default: )
- uris - A list of URIs from which to fetch software or check for updates. (default: )
- suites - Suites in which to narrow available software. (default: )
- components - Components of the source repository to enable. (default: )
- signed_by - The path to the signing key for this source
- file - The File object for this source
- key - The Key object for this source.
- twin_source: - This source should be saved with both binary and source code types enabled.
The following decribe how each of these are used.
ident is the system-identifier for this source. This determines the
filename the source will use on-disk as well as the way to specify a source to
This is a human-readable and nicely-formatted name to help a user recognize what this source is. Any unicode character is allowed in this field. If a source is opened which doesn’t have a name field, the filename will be used.
name is a string value, set to
'' by default. If there is no name in
a loaded source, it will be set to the same as the filename (minus the
This field maps to the
X-Repolib-Name: field in the .sources file, which
is ignored by Apt and other standards-compliant sources parsers.
Apt sources can be disbaled without removing them entirely from the system. A
disabled source is excluded from updates and new software installs, but it can
be easily re-enabled at any time. It defaults to
This field maps to the
Enabled: field in the .sources file. This is optional
per the DEB822 standard, however if set to anything other than
source is considered enabled.
Debian archives may contain either binary packages or source code packages, and
this value specifies which of those Apt should look for in the source.
is used to look for binary packages, while
deb-src looks for source code
packages. RepoLib stores this value as a list of aptsourcetype-enum`s, and
defaults to ``[AptSourceType.BINARY]`.
This field maps to the
Types: field in the sources file.
A list of string values describing the URIs from which to fetch package lists and software for updates and installs. The currently recognized URI types are:
DEB822 sources may directly contain an arbitrary number of URIs. Legacy sources may also have multiple URIs; however, these require writing a new deb line for each URI as the one-line format only allows a single URI per source.
Although these are the currently-recognized official URI types, Apt can be extended with additional URI schemes through extension packages. Thus it is not recommended to parse URIs by type and instead rely on user input being correct and to throw exceptions when that isn’t the case.
The Suite, also known as the distribution specifies a subdirectory of the
main archive root in which to look for software. This is typically used to
differentiate versions for the same OS, e.g.
cosmic for Ubuntu,
unstable for Debian.
DEB822 Sources allow specifying an arbitrary number of suites. One-line sources also support multiple suites, but require an additional repo line for each as the one-line format only allows a single suite for each source.
This value maps to the
Suites: field in the sources file.
This value is a list of strings describing the enabled distro components to
download software from. Common values include
The path to the keyring containing the signing key used to verify packages downloaded from this repository. This should generally match the key-path attribute for this source’s key object.
- Source.get_description() -> str
- Returns a
strcontaining a UI-compatible description of the source.
- Initializes the Source’s attributes with default data in-order. This is recommended to ensure that the fields in the underlying deb822 Dict are in order and correctly capitalized.
- Source.load_from_data(data: list) -> None
- Loads configuration information from a list of data, rather than using manual entry. The data can either be a list of strings with DEB822 data, or a single-element list containing a one-line legacy line.
The data load load into the source. If this contains a legacy-format one-line repository, it must be a single-element list. Otherwise, it should contain a list of strings, each being a line from a DEB822 configuration.
- Source.generate_default_ident(prefix: str = ‘’) -> str
- Generates a suitable default ident, optionally with a prefix, and sets it. The generated ident is also returned for processing convenience.
The prefix to prepend to the ident.
- Source.generate_default_name() ->
- Generates a default name for the source and sets it. The generated name is also returned for convenience.
If False, raise a exc_sourceerror if the key can’t be loaded or doesn’t exist.
- Proxy method for the file-save method for this source’s File object.
There are three output properties which contain the current source data for output in a variety of formats.
- A representation of the source data as a DEB822-formatted string
- A one-line formatted string of the source. It twin_source is
True, then there will additionally be a
deb-srcline following the primary line.
- A representation of the source with certain key names translated to better represent their use in a UI for display to a user.