Skip to main content

specfile.sources

Source

class Source(ABC)

Class that represents a source.

number

@property
@abstractmethod
def number() -> int

Source number.

location

@property
@abstractmethod
def location() -> str

Literal location of the source as stored in the spec file.

expanded_location

@property
@abstractmethod
def expanded_location() -> Optional[str]

Location of the source after expanding macros.

filename

@property
@abstractmethod
def filename() -> str

Literal filename of the source.

remote

@property
def remote() -> bool

Whether the source is remote (location is URL).

expanded_filename

@property
@abstractmethod
def expanded_filename() -> Optional[str]

Filename of the source after expanding macros.

comments

@property
@abstractmethod
def comments() -> Comments

List of comments associated with the source.

valid

@property
@abstractmethod
def valid() -> bool

Whether the source is not located in a false branch of a condition.

TagSource

class TagSource(Source)

Class that represents a source backed by a spec file tag.

__init__

def __init__(tag: Tag, number: Optional[int] = None) -> None

Initializes a tag source object.

Arguments:

  • tag - Tag that this source represents.
  • number - Source number (in the case of implicit numbering).

number

@property
def number() -> int

Source number.

number_digits

@property
def number_digits() -> int

Gets number of digits in the source number.

Returns 0 if the source has no number, 1 if the source number has no leading zeros and the actual number of digits if there are any leading zeros.

location

@property
def location() -> str

Literal location of the source as stored in the spec file.

expanded_location

@property
def expanded_location() -> Optional[str]

Location of the source after expanding macros.

filename

@property
def filename() -> str

Literal filename of the source.

expanded_filename

@property
def expanded_filename() -> Optional[str]

Filename of the source after expanding macros.

comments

@property
def comments() -> Comments

List of comments associated with the source.

valid

@property
def valid() -> bool

Whether the source is not located in a false branch of a condition.

ListSource

class ListSource(Source)

Class that represents a source backed by a line in a %sourcelist section.

__init__

def __init__(source: SourcelistEntry, number: int) -> None

Initializes a list source object.

Arguments:

  • source - Sourcelist entry that this source represents.
  • number - Source number.

number

@property
def number() -> int

Source number.

location

@property
def location() -> str

Literal location of the source as stored in the spec file.

expanded_location

@property
def expanded_location() -> str

Location of the source after expanding macros.

filename

@property
def filename() -> str

Literal filename of the source.

expanded_filename

@property
def expanded_filename() -> str

Filename of the source after expanding macros.

comments

@property
def comments() -> Comments

List of comments associated with the source.

valid

@property
def valid() -> bool

Whether the source is not located in a false branch of a condition.

Sources

class Sources(collections.abc.MutableSequence)

Class that represents a sequence of all sources.

__init__

def __init__(tags: Tags,
sourcelists: List[Sourcelist],
allow_duplicates: bool = False,
default_to_implicit_numbering: bool = False,
default_source_number_digits: int = 1,
context: Optional["Specfile"] = None) -> None

Initializes a sources object.

Arguments:

  • tags - All spec file tags.
  • sourcelists - List of all %sourcelist sections.
  • allow_duplicates - Whether to allow duplicate entries when adding new sources.
  • default_to_implicit_numbering - Use implicit numbering (no source numbers) by default.
  • default_source_number_digits - Default number of digits in a source number.
  • context - Specfile instance that defines the context for macro expansions.

insert

def insert(i: int, location: str) -> None

Inserts a new source at a specified index.

Arguments:

  • i - Requested index.
  • location - Location of the new source.

Raises:

  • DuplicateSourceException - If duplicates are disallowed and there already is a source with the same location.

insert_numbered

def insert_numbered(number: int, location: str) -> int

Inserts a new source with the specified number.

Arguments:

  • number - Number of the new source.
  • location - Location of the new source.

Returns:

Index of the newly inserted source.

Raises:

  • DuplicateSourceException - If duplicates are disallowed and there already is a source with the same location.

remove

def remove(location: str) -> None

Removes sources by location.

Arguments:

  • location - Location of the sources to be removed.

remove_numbered

def remove_numbered(number: int) -> None

Removes a source by number.

Arguments:

  • number - Number of the source to be removed.

count

def count(location: str) -> int

Counts sources by location.

Arguments:

  • location - Location of the sources to be counted.

Returns:

Number of sources with the specified location.

Patch

class Patch(Source)

Class that represents a patch.

TagPatch

class TagPatch(TagSource, Patch)

Class that represents a patch backed by a spec file tag.

ListPatch

class ListPatch(ListSource, Patch)

Class that represents a patch backed by a line in a %patchlist section.

Patches

class Patches(Sources)

Class that represents a sequence of all patches.