Skip to main content

specfile.changelog

ChangelogEntry

class ChangelogEntry()

Class that represents a changelog entry. Changelog entry consists of a header line starting with *, followed by timestamp, author and optional extra text (usually EVR), and one or more content lines.

Attributes:

  • header - Header of the entry.
  • content - List of lines forming the content of the entry.

__init__

def __init__(header: str,
content: List[str],
following_lines: Optional[List[str]] = None) -> None

Initializes a changelog entry object.

Arguments:

  • header - Header of the entry.
  • content - List of lines forming the content of the entry.
  • following_lines - Extra lines that follow the entry.

evr

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

EVR (epoch, version, release) of the entry.

extended_timestamp

@property
def extended_timestamp() -> bool

Whether the timestamp present in the entry header is extended (date and time).

day_of_month_padding

@property
def day_of_month_padding() -> str

Padding of day of month in the entry header timestamp

assemble

@classmethod
def assemble(cls,
timestamp: Union[datetime.date, datetime.datetime],
author: str,
content: List[str],
evr: Optional[str] = None,
day_of_month_padding: str = "0",
append_newline: bool = True) -> "ChangelogEntry"

Assembles a changelog entry.

Arguments:

  • timestamp - Timestamp of the entry. Supply datetime rather than date for extended format.
  • author - Author of the entry.
  • content - List of lines forming the content of the entry.
  • evr - EVR (epoch, version, release) of the entry.
  • day_of_month_padding - Padding to apply to day of month in the timestamp.
  • append_newline - Whether the entry should be followed by an empty line.

Returns:

New instance of ChangelogEntry class.

Changelog

class Changelog(UserList[ChangelogEntry])

Class that represents a changelog. It behaves like a list of changelog entries, ordered from bottom to top - the top (newest) entry has index -1, the bottom (oldest) one has index 0.

Attributes:

  • data - List of individual entries.

__init__

def __init__(data: Optional[List[ChangelogEntry]] = None,
predecessor: Optional[List[str]] = None) -> None

Initializes a changelog object.

Arguments:

  • data - List of individual changelog entries.
  • predecessor - List of lines at the beginning of a section that can't be parsed into changelog entries.

filter

def filter(since: Optional[str] = None,
until: Optional[str] = None) -> "Changelog"

Filters changelog entries with EVR between since and until.

Arguments:

  • since - Optional lower bound. If specified, entries with EVR higher than or equal to this will be included.
  • until - Optional upper bound. If specified, entries with EVR lower than or equal to this will be included.

Returns:

Filtered changelog.

parse

@classmethod
def parse(cls, section: Section) -> "Changelog"

Parses a %changelog section.

Arguments:

  • section - Section to parse.

Returns:

New instance of Changelog class.

get_raw_section_data

def get_raw_section_data() -> List[str]

Reconstructs section data from changelog.

Returns:

List of lines forming the reconstructed section data.

guess_packager

def guess_packager() -> str

Guesses the name and e-mail of a packager to use for changelog entries. This function uses logic similar to rpmdev-packager utility.

The following places are searched for this value (in this order):

  • $RPM_PACKAGER environment variable
  • %packager macro
  • git config
  • Unix username

Returns:

A string to use for the changelog entry author. If nothing was detected, an empty string is returned.