# `gbp.rpm.SpecFile(object)` class documentation

Part of `gbp.rpm` (View In Hierarchy)

Class for parsing/modifying spec files

Class Variable | tag_re | Undocumented
Class Variable | directive_re | Undocumented
Class Variable | gbptag_re | Undocumented
Class Variable | section_identifiers | Undocumented
Method | __init__ | Undocumented
Instance Variable | specfile | Undocumented
Instance Variable | specdir | Undocumented
Instance Variable | name | Undocumented
Instance Variable | upstreamversion | Undocumented
Instance Variable | release | Undocumented
Instance Variable | epoch | Undocumented
Instance Variable | packager | Undocumented
Instance Variable | orig_src | Undocumented
Method | version | Get the (downstream) version
Method | specpath | Get the dir/filename
Method | ignorepatches | Get numbers of ignored patches as a sorted list
Method | sources | Get all source tags as a dict
Method | macro_expand | Expand the rpm macros (that gbp knows of) in the given text.
Method | write_spec_file | Write, possibly updated, spec to disk
Method | set_tag | Update a tag in spec file content
Method | set_changelog | Update or create the %changelog section
Method | get_changelog | Get the %changelog section
Method | update_patches | Update spec with new patch tags and patch macros
Method | patchseries | Return non-ignored patches of the RPM as a gbp patchseries
Instance Variable | _content | Undocumented
Instance Variable | _filtertags | Undocumented
Instance Variable | _listtags | Undocumented
Instance Variable | _specinfo | Undocumented
Instance Variable | _tags | Undocumented
Instance Variable | _special_directives | Undocumented
Instance Variable | _gbp_tags | Undocumented
Method | _parse_filtered_spec | Parse a filtered spec file in rpm-python
Method | _patches | Get all patch tags as a dict
Method | _sources | Get all source tags as a dict
Method | _macro_replace | Undocumented
Method | _parse_tag | Parse tag line
Static Method | _patch_macro_opts | Parse arguments of the '%patch' macro
Static Method | _setup_macro_opts | Parse arguments of the '%setup' macro
Method | _parse_directive | Parse special directive/scriptlet/macro lines
Method | _parse_gbp_tag | Parse special git-buildpackage tags
Method | _parse_content | Go through spec file content line-by-line and (re-)parse info from it
Method | _delete_tag | Delete a tag
Method | _set_tag | Set a tag value
Method | _delete_special_macro | Delete a special macro line in spec file content
Method | _set_special_macro | Update a special macro line in spec file content
Method | _set_section | Update/create a complete section in spec file.
Method | _guess_orig_prefix | Guess prefix for the orig file
Method | _guess_orig_file | Try to guess the name of the primary upstream/source archive. Returns a dict with all the relevant information.

tag_re =
Undocumented
directive_re =
Undocumented
gbptag_re =
Undocumented
section_identifiers =
Undocumented
(type: `Tuple[str, ...]`)
def __init__(self, filename=None, filedata=None):
Undocumented
_content =
Undocumented
specfile =
Undocumented
specdir =
Undocumented
_filtertags =
Undocumented
(type: `Tuple[str, ...]`)
_listtags =
Undocumented
_specinfo =
Undocumented
name =
Undocumented
upstreamversion =
Undocumented
release =
Undocumented
epoch =
Undocumented
packager =
Undocumented
_tags =
Undocumented
(type: `Dict`)
_special_directives =
Undocumented
_gbp_tags =
Undocumented
orig_src =
Undocumented
def _parse_filtered_spec(self, skip_tags):

Parse a filtered spec file in rpm-python

@property
def version(self):

Get the (downstream) version

@property
def specpath(self):

Get the dir/filename

@property
def ignorepatches(self):

Get numbers of ignored patches as a sorted list

def _patches(self):

Get all patch tags as a dict

def _sources(self):

Get all source tags as a dict

def sources(self):

Get all source tags as a dict

def _macro_replace(self, matchobj):
Undocumented
def macro_expand(self, text):

Expand the rpm macros (that gbp knows of) in the given text.

Parameters | text | text to check for macros (type: `str`)
Returns | text with macros expanded (type: `str`)

def write_spec_file(self):

Write, possibly updated, spec to disk

def _parse_tag(self, lineobj):

Parse tag line

@staticmethod
def _patch_macro_opts(args):

Parse arguments of the '%patch' macro

@staticmethod
def _setup_macro_opts(args):

Parse arguments of the '%setup' macro

def _parse_directive(self, lineobj):

Parse special directive/scriptlet/macro lines

def _parse_gbp_tag(self, linenum, lineobj):

Parse special git-buildpackage tags

def _parse_content(self):

Go through spec file content line-by-line and (re-)parse info from it

def _delete_tag(self, tag, num):

Delete a tag

def _set_tag(self, tag, num, value, insertafter):

Set a tag value

def set_tag(self, tag, num, value, insertafter=None):

Update a tag in spec file content

def _delete_special_macro(self, name, identifier):

Delete a special macro line in spec file content

def _set_special_macro(self, name, identifier, args, insertafter):

Update a special macro line in spec file content

def _set_section(self, name, text):

Update/create a complete section in spec file.

def set_changelog(self, text):

Update or create the %changelog section

def get_changelog(self):

Get the %changelog section

def update_patches(self, patches, commands):

Update spec with new patch tags and patch macros

def patchseries(self, unapplied=(False), ignored=(False)):

Return non-ignored patches of the RPM as a gbp patchseries

def _guess_orig_prefix(self, orig):

Guess prefix for the orig file

def _guess_orig_file(self):

Try to guess the name of the primary upstream/source archive. Returns a dict with all the relevant information.