Skip to main content

specfile.utils

EVR

class EVR(collections.abc.Hashable)

Class representing Epoch-Version-Release combination.

NEVR

class NEVR(EVR)

Class representing Name-Epoch-Version-Release combination.

NEVRA

class NEVRA(NEVR)

Class representing Name-Epoch-Version-Release-Arch combination.

get_filename_from_location

def get_filename_from_location(location: str) -> str

Extracts filename from given source location.

Follows RPM logic - target filename can be specified in URL fragment.

Arguments:

  • location - Location to extract filename from.

Returns:

Extracted filename that can be empty if there is none.

count_brackets

def count_brackets(string: str) -> Tuple[int, int]

Counts non-pair brackets in %{...} and %(...) expressions appearing in the given string.

Arguments:

  • string - Input string.

Returns:

The count of non-pair curly braces and the count of non-pair parentheses.

split_conditional_macro_expansion

def split_conditional_macro_expansion(value: str) -> Tuple[str, str, str]

Splits conditional macro expansion into its body and prefix and suffix of it. If the passed string isn't a conditional macro expansion, returns it as it is.

Arguments:

  • value - String to be split.

Returns:

Tuple of body, prefix, suffix. Prefix and suffix will be empty if the passed string isn't a conditional macro expansion.