Hello community, here is the log from the commit of package python-python-rpm-spec for openSUSE:Factory checked in at 2020-08-06 10:42:04 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-python-rpm-spec (Old) and /work/SRC/openSUSE:Factory/.python-python-rpm-spec.new.3399 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-python-rpm-spec" Thu Aug 6 10:42:04 2020 rev:4 rq:824577 version:0.9 Changes: -------- --- /work/SRC/openSUSE:Factory/python-python-rpm-spec/python-python-rpm-spec.changes 2019-03-12 09:52:32.311548540 +0100 +++ /work/SRC/openSUSE:Factory/.python-python-rpm-spec.new.3399/python-python-rpm-spec.changes 2020-08-06 10:42:10.066121469 +0200 @@ -1,0 +2,6 @@ +Wed Aug 5 09:18:10 UTC 2020 - Marketa Calabkova <mcalabk...@suse.com> + +- update to 0.9 + * Ignore case when parsing directives + +------------------------------------------------------------------- Old: ---- python-rpm-spec-0.8.tar.gz New: ---- python-rpm-spec-0.9.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-python-rpm-spec.spec ++++++ --- /var/tmp/diff_new_pack.I4Re7u/_old 2020-08-06 10:42:12.658122766 +0200 +++ /var/tmp/diff_new_pack.I4Re7u/_new 2020-08-06 10:42:12.658122766 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-python-rpm-spec # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %define skip_python2 1 %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-python-rpm-spec -Version: 0.8 +Version: 0.9 Release: 0 Summary: Python module for parsing RPM spec files License: MIT @@ -51,7 +51,7 @@ %python_expand %fdupes %{buildroot}%{$python_sitelib} %check -%python_expand py.test-%{$python_bin_suffix} -vv tests +%pytest tests %files %{python_files} %doc CHANGELOG* README* ++++++ python-rpm-spec-0.8.tar.gz -> python-rpm-spec-0.9.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-spec-0.8/.editorconfig new/python-rpm-spec-0.9/.editorconfig --- old/python-rpm-spec-0.8/.editorconfig 1970-01-01 01:00:00.000000000 +0100 +++ new/python-rpm-spec-0.9/.editorconfig 2020-05-02 14:29:17.260953200 +0200 @@ -0,0 +1,8 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +insert_final_newline = true +end_of_line = lf diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-spec-0.8/.pylintrc new/python-rpm-spec-0.9/.pylintrc --- old/python-rpm-spec-0.8/.pylintrc 2018-09-18 21:35:11.181484200 +0200 +++ new/python-rpm-spec-0.9/.pylintrc 2020-03-01 12:31:05.475503000 +0100 @@ -143,6 +143,7 @@ C0103, C0111, C0111, + C0330, # Wrong hanging indentation before block C0413, E1101, R0903, @@ -324,7 +325,7 @@ indent-string=' ' # Maximum number of characters on a single line. -max-line-length=100 +max-line-length=110 # Maximum number of lines in a module. max-module-lines=1000 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-spec-0.8/AUTHORS new/python-rpm-spec-0.9/AUTHORS --- old/python-rpm-spec-0.8/AUTHORS 2018-09-18 19:00:37.772446900 +0200 +++ new/python-rpm-spec-0.9/AUTHORS 2020-05-02 14:29:17.262953300 +0200 @@ -1,4 +1,6 @@ Benjamin Kircher <benjamin.kirc...@gmail.com> +Clément Bénier <clement.ben...@iot.bzh> +KOLANICH <kola...@mail.ru> Lazar Šumar <bugzi...@lazar.co.nz> Lon Hohberger <l...@metamorphism.com> Luca Beltrame <lbeltr...@kde.org> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-spec-0.8/CHANGELOG.md new/python-rpm-spec-0.9/CHANGELOG.md --- old/python-rpm-spec-0.8/CHANGELOG.md 2018-09-18 21:47:51.851634000 +0200 +++ new/python-rpm-spec-0.9/CHANGELOG.md 2020-05-02 15:05:15.548065000 +0200 @@ -1,8 +1,15 @@ # Changelog +## 0.9 (202-05-02) + +Changes: + +* Ignore case when parsing directives + ## 0.8 (2018-09-18) New Features: + * Enable parsing versions in `BuildRequires:` and `Requires:` * Add support for conditional macros, e.g. `%{?test_macro:expression}` * Use flit for packaging @@ -10,4 +17,5 @@ ## 0.7 (2017-08-10) New Features: + * Add `Spec.sources_dict` and `Spec.patches_dict` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-spec-0.8/PKG-INFO new/python-rpm-spec-0.9/PKG-INFO --- old/python-rpm-spec-0.8/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 +++ new/python-rpm-spec-0.9/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 @@ -1,7 +1,7 @@ Metadata-Version: 1.1 Name: python-rpm-spec -Version: 0.8 +Version: 0.9 Summary: python-rpm-spec is a Python library for parsing RPM spec files. Home-page: https://github.com/bkircher/python-rpm-spec Author: Benjamin Kircher -Author-email: benjamin.kirc...@gmail.com +Author-email: bkirc...@0xadd.de diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-spec-0.8/README.md new/python-rpm-spec-0.9/README.md --- old/python-rpm-spec-0.8/README.md 2018-09-18 21:38:37.635101600 +0200 +++ new/python-rpm-spec-0.9/README.md 2020-03-01 12:31:05.628504300 +0100 @@ -7,6 +7,7 @@ tl;dr If you want to quickly parse a spec file on the command line you might want to give `rpmspec --parse` a try. + ```sh $ rpmspec --parse file.spec | awk '/Source/ {print $2}' ``` @@ -20,11 +21,14 @@ spec file. ## Features + * No extra dependencies other than Python 3 * Available on all platforms, parse spec files on Windows ## Examples + This is how you access a spec file's various definitions: + ```python from pyrpm.spec import Spec, replace_macros @@ -45,6 +49,7 @@ ``` Example showing how to retrieve named source or patch files from a spec: + ```python from pyrpm.spec import Spec @@ -67,6 +72,7 @@ Example showing how to get versioned `BuildRequires:` and `Requires:` out of a spec file: + ```python from pyrpm.spec import Spec @@ -87,9 +93,10 @@ ## Install -python-rpm-spec is hosted on PyPI - the Python Package Index. So all you need to do is +python-rpm-spec is [hosted](https://pypi.org/project/python-rpm-spec/) on PyPI - +the Python Package Index. So all you need to do is -```bash +```sh $ pip install python-rpm-spec ``` @@ -99,23 +106,26 @@ package manager to install a python-rpm-spec as a normal package in your system. -```bash +```sh $ sudo dnf copr enable bkircher/python-rpm-spec # Enable copr repo $ sudo dnf install -y python3-rpm-spec # Install the package ``` ## Dependencies + Except Python 3 no extra dependencies are required. No Python 2, sorry. ## Current status + This module does not parse everything of a spec file. Only the pieces I needed. So there is probably still plenty of stuff missing. However, it should not be terribly complicated to add support for the missing pieces. ## Development + If you want to hack on this module you could start with following recipe: -```bash +```sh $ git clone https://github.com/bkircher/python-rpm-spec.git # Clone the repo $ cd python-rpm-spec # Change into the source directory $ mkdir .venv && python3 -m venv .venv # Create a virtual environment @@ -123,7 +133,9 @@ $ pip install pytest # Install py.test $ pytest # Execute all tests ``` -Happy hacking! -<!-- vim: et sw=4 ts=4: ---> +## Further references + +Take a look at the excellent [RPM Packaging Guide](https://rpm-guide.readthedocs.io/en/latest/index.html), especially the section [What is a SPEC File?](https://rpm-guide.readthedocs.io/en/latest/rpm-guide.html#what-is-a-spec-file) + +Happy hacking! diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-spec-0.8/dev-requirements.txt new/python-rpm-spec-0.9/dev-requirements.txt --- old/python-rpm-spec-0.8/dev-requirements.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/python-rpm-spec-0.9/dev-requirements.txt 2020-05-02 14:31:06.988873200 +0200 @@ -0,0 +1,5 @@ +black +flit +pylint +pytest +rope diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-spec-0.8/environment.yaml new/python-rpm-spec-0.9/environment.yaml --- old/python-rpm-spec-0.8/environment.yaml 2018-09-18 21:21:25.493612500 +0200 +++ new/python-rpm-spec-0.9/environment.yaml 2020-03-01 12:31:05.691505000 +0100 @@ -1,8 +1,9 @@ +name: pyrpm dependencies: - python>=3.7.0 - pip: - - autopep8==1.4 - - flit>=1.1 - - pylint==2.1.1 - - pytest==3.8.0 - - rope==0.11.0 + - black + - flit + - pylint + - pytest + - rope diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-spec-0.8/pyproject.toml new/python-rpm-spec-0.9/pyproject.toml --- old/python-rpm-spec-0.8/pyproject.toml 2018-09-18 22:02:18.265167200 +0200 +++ new/python-rpm-spec-0.9/pyproject.toml 2020-05-02 15:07:49.916006600 +0200 @@ -6,7 +6,7 @@ dist-name = "python-rpm-spec" module = "pyrpm" author = "Benjamin Kircher" -author-email = "benjamin.kirc...@gmail.com" +author-email = "bkirc...@0xadd.de" home-page = "https://github.com/bkircher/python-rpm-spec" requires-python = ">=3.3" description-file = "README.md" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-spec-0.8/pyrpm/__init__.py new/python-rpm-spec-0.9/pyrpm/__init__.py --- old/python-rpm-spec-0.8/pyrpm/__init__.py 2018-09-18 21:53:00.132422700 +0200 +++ new/python-rpm-spec-0.9/pyrpm/__init__.py 2020-05-02 15:07:32.983013000 +0200 @@ -2,4 +2,4 @@ """ -__version__ = "0.8" +__version__ = "0.9" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-spec-0.8/pyrpm/spec.py new/python-rpm-spec-0.9/pyrpm/spec.py --- old/python-rpm-spec-0.8/pyrpm/spec.py 2018-09-18 18:58:06.209234200 +0200 +++ new/python-rpm-spec-0.9/pyrpm/spec.py 2020-05-02 14:47:30.966467100 +0200 @@ -11,9 +11,9 @@ """ import re -from abc import (ABCMeta, abstractmethod) +from abc import ABCMeta, abstractmethod -__all__ = ['Spec', 'replace_macros', 'Package'] +__all__ = ["Spec", "replace_macros", "Package"] class _Tag(metaclass=ABCMeta): @@ -49,8 +49,8 @@ @staticmethod def current_target(spec_obj, context): target_obj = spec_obj - if context['current_subpackage'] is not None: - target_obj = context['current_subpackage'] + if context["current_subpackage"] is not None: + target_obj = context["current_subpackage"] return target_obj @@ -65,7 +65,7 @@ value = match_obj.group(1) # Sub-packages - if self.name == 'name': + if self.name == "name": spec_obj.packages = [] spec_obj.packages.append(Package(value)) @@ -98,16 +98,22 @@ setattr(target_obj, self.name, list()) value = match_obj.group(1) - if self.name == 'packages': - if value == '-n': - subpackage_name = line.rsplit(' ', 1)[-1].rstrip() + if self.name == "packages": + if value == "-n": + subpackage_name = line.rsplit(" ", 1)[-1].rstrip() else: - subpackage_name = '{}-{}'.format(spec_obj.name, value) + subpackage_name = "{}-{}".format(spec_obj.name, value) package = Package(subpackage_name) - context['current_subpackage'] = package + context["current_subpackage"] = package package.is_subpackage = True spec_obj.packages.append(package) - elif self.name in ['build_requires', 'requires', 'conflicts', 'obsoletes', 'provides']: + elif self.name in [ + "build_requires", + "requires", + "conflicts", + "obsoletes", + "provides", + ]: # Macros are valid in requirements value = replace_macros(value, spec=spec_obj) @@ -117,7 +123,7 @@ # Requires: a, b >= 3.1, c # 1. Tokenize - tokens = [val for val in re.split('[\t\n, ]', value) if val != ''] + tokens = [val for val in re.split("[\t\n, ]", value) if val != ""] values = [] # 2. Join @@ -125,10 +131,10 @@ for val in tokens: if add: add = False - val = values.pop() + ' ' + val - elif val in ['>=', '!=', '>', '<', '<=', '==', '=']: + val = values.pop() + " " + val + elif val in [">=", "!=", ">", "<", "<=", "==", "="]: add = True # Add next value to this one - val = values.pop() + ' ' + val + val = values.pop() + " " + val values.append(val) for val in values: @@ -148,37 +154,39 @@ def update_impl(self, spec_obj, context, match_obj, line): source_name, value = match_obj.groups() - dictionary = getattr(spec_obj, '{}_dict'.format(self.name)) + dictionary = getattr(spec_obj, "{}_dict".format(self.name)) dictionary[source_name] = value target_obj = _Tag.current_target(spec_obj, context) getattr(target_obj, self.name).append(value) return spec_obj, context +def re_tag_compile(tag): + return re.compile(tag, re.IGNORECASE) _tags = [ - _NameValue('name', re.compile(r'^Name:\s*(\S+)')), - _NameValue('version', re.compile(r'^Version:\s*(\S+)')), - _NameValue('epoch', re.compile(r'^Epoch:\s*(\S+)')), - _NameValue('release', re.compile(r'^Release:\s*(\S+)')), - _NameValue('summary', re.compile(r'^Summary:\s*(.+)')), - _NameValue('license', re.compile(r'^License:\s*(.+)')), - _NameValue('group', re.compile(r'^Group:\s*(\S+)')), - _NameValue('url', re.compile(r'^URL:\s*(\S+)')), - _NameValue('buildroot', re.compile(r'^BuildRoot:\s*(\S+)')), - _NameValue('buildarch', re.compile(r'^BuildArch:\s*(\S+)')), - _ListAndDict('sources', re.compile(r'^(Source\d*):\s*(\S+)')), - _ListAndDict('patches', re.compile(r'^(Patch\d*):\s*(\S+)')), - _List('build_requires', re.compile(r'^BuildRequires:\s*(.+)')), - _List('requires', re.compile(r'^Requires:\s*(.+)')), - _List('conflicts', re.compile(r'^Conflicts:\s*(.+)')), - _List('obsoletes', re.compile(r'^Obsoletes:\s*(.+)')), - _List('provides', re.compile(r'^Provides:\s*(.+)')), - _List('packages', re.compile(r'^%package\s+(\S+)')), - _MacroDef('define', re.compile(r'^%define\s+(\S+)\s+(\S+)')), - _MacroDef('global', re.compile(r'^%global\s+(\S+)\s+(\S+)')) + _NameValue("name", re_tag_compile(r"^Name:\s*(\S+)")), + _NameValue("version", re_tag_compile(r"^Version:\s*(\S+)")), + _NameValue("epoch", re_tag_compile(r"^Epoch:\s*(\S+)")), + _NameValue("release", re_tag_compile(r"^Release:\s*(\S+)")), + _NameValue("summary", re_tag_compile(r"^Summary:\s*(.+)")), + _NameValue("license", re_tag_compile(r"^License:\s*(.+)")), + _NameValue("group", re_tag_compile(r"^Group:\s*(\S+)")), + _NameValue("url", re_tag_compile(r"^URL:\s*(\S+)")), + _NameValue("buildroot", re_tag_compile(r"^BuildRoot:\s*(\S+)")), + _NameValue("buildarch", re_tag_compile(r"^BuildArch:\s*(\S+)")), + _ListAndDict("sources", re_tag_compile(r"^(Source\d*):\s*(\S+)")), + _ListAndDict("patches", re_tag_compile(r"^(Patch\d*):\s*(\S+)")), + _List("build_requires", re_tag_compile(r"^BuildRequires:\s*(.+)")), + _List("requires", re_tag_compile(r"^Requires:\s*(.+)")), + _List("conflicts", re_tag_compile(r"^Conflicts:\s*(.+)")), + _List("obsoletes", re_tag_compile(r"^Obsoletes:\s*(.+)")), + _List("provides", re_tag_compile(r"^Provides:\s*(.+)")), + _List("packages", re.compile(r"^%package\s+(\S+)")), + _MacroDef("define", re.compile(r"^%define\s+(\S+)\s+(\S+)")), + _MacroDef("global", re.compile(r"^%global\s+(\S+)\s+(\S+)")), ] -_macro_pattern = re.compile(r'%{(\S+?)\}') +_macro_pattern = re.compile(r"%{(\S+?)\}") def _parse(spec_obj, context, line): @@ -192,7 +200,7 @@ class Requirement: """Represents a single requirement or build requirement in an RPM spec file. - Each spec file contains one or more requirements or build requirements. + Each spec file contains one or more requirements or build requirements. For example, consider following spec file:: Name: foo @@ -215,7 +223,8 @@ This spec file's requirements have a name and either a required or minimum version. """ - expr = re.compile(r'(.*?)\s+([<>]=?|=)\s+(\S+)') + + expr = re.compile(r"(.*?)\s+([<>]=?|=)\s+(\S+)") def __init__(self, name): assert isinstance(name, str) @@ -279,8 +288,13 @@ assert isinstance(name, str) for tag in _tags: - if tag.attr_type is list and tag.name in ["build_requires", "requires", "conflicts", "obsoletes", - "provides"]: + if tag.attr_type is list and tag.name in [ + "build_requires", + "requires", + "conflicts", + "obsoletes", + "provides", + ]: setattr(self, tag.name, tag.attr_type()) self.name = name @@ -326,10 +340,8 @@ """ spec = Spec() - with open(filename, 'r', encoding='utf-8') as f: - parse_context = { - 'current_subpackage': None - } + with open(filename, "r", encoding="utf-8") as f: + parse_context = {"current_subpackage": None} for line in f: spec, parse_context = _parse(spec, parse_context, line) return spec @@ -343,9 +355,7 @@ """ spec = Spec() - parse_context = { - 'current_subpackage': None - } + parse_context = {"current_subpackage": None} for line in string.splitlines(): spec, parse_context = _parse(spec, parse_context, line) return spec @@ -380,29 +390,29 @@ macro_name = match.group(1) if _is_conditional(macro_name) and spec: parts = macro_name[1:].split(sep=":", maxsplit=1) - assert len(parts) > 0 - if _test_conditional(macro_name): # ? + assert parts + if _test_conditional(macro_name): if hasattr(spec, parts[0]): if len(parts) == 2: return parts[1] - else: - return getattr(spec, parts[0], None) - else: - return "" - else: # ! - if not hasattr(spec, parts[0]): - if len(parts) == 2: - return parts[1] - else: - return getattr(spec, parts[0], None) - else: - return "" + + return getattr(spec, parts[0], None) + + return "" + + if not hasattr(spec, parts[0]): + if len(parts) == 2: + return parts[1] + + return getattr(spec, parts[0], None) + + return "" if spec: value = getattr(spec, macro_name, None) if value: return str(value) - return match.string[match.start():match.end()] + return match.string[match.start() : match.end()] # Recursively expand macros # Note: If macros are not defined in the spec file, this won't try to diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-spec-0.8/setup.py new/python-rpm-spec-0.9/setup.py --- old/python-rpm-spec-0.8/setup.py 1970-01-01 01:00:00.000000000 +0100 +++ new/python-rpm-spec-0.9/setup.py 1970-01-01 01:00:00.000000000 +0100 @@ -10,10 +10,10 @@ {'': ['*']} setup(name='python-rpm-spec', - version='0.8', + version='0.9', description='python-rpm-spec is a Python library for parsing RPM spec files.', author='Benjamin Kircher', - author_email='benjamin.kirc...@gmail.com', + author_email='bkirc...@0xadd.de', url='https://github.com/bkircher/python-rpm-spec', packages=packages, package_data=package_data, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-spec-0.8/tests/test_spec_file_parser.py new/python-rpm-spec-0.9/tests/test_spec_file_parser.py --- old/python-rpm-spec-0.8/tests/test_spec_file_parser.py 2018-09-18 18:58:23.725536600 +0200 +++ new/python-rpm-spec-0.9/tests/test_spec_file_parser.py 2020-05-02 14:43:25.667559600 +0200 @@ -7,123 +7,127 @@ class TestPackageClass: def test_repr_string(self): - package = Package('foo') - assert package.name == 'foo' + package = Package("foo") + assert package.name == "foo" assert str(package) == "Package('foo')" def test_is_subpackage(self): - package = Package('foo') + package = Package("foo") assert package.is_subpackage is False class TestSpecFileParser: def test_parse_perl_array_compare_spec(self): - spec = Spec.from_file(os.path.join(CURRENT_DIR, 'perl-Array-Compare.spec')) + spec = Spec.from_file(os.path.join(CURRENT_DIR, "perl-Array-Compare.spec")) assert isinstance(spec, Spec) - assert 'perl-Array-Compare' == spec.name - assert 'Perl extension for comparing arrays' == spec.summary - assert '1' == spec.epoch - - assert '1.16' == spec.version - assert 'noarch' == spec.buildarch - assert 2 == len(spec.build_requires) - assert 'perl >= 1:5.6.0' == spec.build_requires[0].line + assert spec.name == "perl-Array-Compare" + assert spec.summary == "Perl extension for comparing arrays" + assert spec.epoch == "1" + + assert spec.version == "1.16" + assert spec.buildarch == "noarch" + assert len(spec.build_requires) == 2 + assert spec.build_requires[0].line == "perl >= 1:5.6.0" def test_parse_llvm_spec(self): - spec = Spec.from_file(os.path.join(CURRENT_DIR, 'llvm.spec')) + spec = Spec.from_file(os.path.join(CURRENT_DIR, "llvm.spec")) - assert 'llvm' == spec.name - assert '3.8.0' == spec.version + assert spec.name == "llvm" + assert spec.version == "3.8.0" - assert 2 == len(spec.sources) - assert 'http://llvm.org/releases/%{version}/%{name}-%{version}.src.tar.xz' == \ - spec.sources[0] - assert 'llvm-config.h' == spec.sources[1] + assert len(spec.sources) == 2 + assert ( + spec.sources[0] + == "http://llvm.org/releases/%{version}/%{name}-%{version}.src.tar.xz" + ) + assert spec.sources[1] == "llvm-config.h" - assert 1 == len(spec.patches) - assert 'llvm-3.7.1-cmake-s390.patch' == spec.patches[0] + assert len(spec.patches) == 1 + assert spec.patches[0] == "llvm-3.7.1-cmake-s390.patch" def test_parse_only_base_package(self): # spec file does not contain %package directive - spec = Spec.from_file(os.path.join(CURRENT_DIR, 'perl-Array-Compare.spec')) + spec = Spec.from_file(os.path.join(CURRENT_DIR, "perl-Array-Compare.spec")) assert len(spec.packages) == 1 - assert spec.packages[0].name == 'perl-Array-Compare' + assert spec.packages[0].name == "perl-Array-Compare" assert not spec.packages[0].is_subpackage def test_parse_subpackages(self): # spec file contains four subpackages and one base package - spec = Spec.from_file(os.path.join(CURRENT_DIR, 'llvm.spec')) + spec = Spec.from_file(os.path.join(CURRENT_DIR, "llvm.spec")) assert len(spec.packages) == 5 for package in spec.packages: assert isinstance(package, Package) - assert package.name.startswith('llvm') + assert package.name.startswith("llvm") def test_parse_subpackage_names(self): # spec file contains %package -n directive - spec = Spec.from_file(os.path.join(CURRENT_DIR, 'jsrdbg.spec')) + spec = Spec.from_file(os.path.join(CURRENT_DIR, "jsrdbg.spec")) assert len(spec.packages) == 3 - expected = ['jrdb', 'jsrdbg', 'jsrdbg-devel'] + expected = ["jrdb", "jsrdbg", "jsrdbg-devel"] actual = [package.name for package in spec.packages] for name in expected: assert name in actual def test_packages_dict_property(self): - spec = Spec.from_file(os.path.join(CURRENT_DIR, 'perl-Array-Compare.spec')) + spec = Spec.from_file(os.path.join(CURRENT_DIR, "perl-Array-Compare.spec")) assert isinstance(spec.packages_dict, dict) assert len(spec.packages_dict) == len(spec.packages) - spec = Spec.from_file(os.path.join(CURRENT_DIR, 'llvm.spec')) + spec = Spec.from_file(os.path.join(CURRENT_DIR, "llvm.spec")) assert isinstance(spec.packages_dict, dict) assert len(spec.packages_dict) == len(spec.packages) def test_sources_dict_property(self): - spec = Spec.from_file(os.path.join(CURRENT_DIR, 'llvm.spec')) + spec = Spec.from_file(os.path.join(CURRENT_DIR, "llvm.spec")) assert len(spec.sources_dict) == len(spec.sources) - assert spec.sources_dict['Source0'] is spec.sources[0] - assert spec.sources_dict['Source100'] is spec.sources[1] + assert spec.sources_dict["Source0"] is spec.sources[0] + assert spec.sources_dict["Source100"] is spec.sources[1] def test_patches_dict_property(self): - spec = Spec.from_file(os.path.join(CURRENT_DIR, 'llvm.spec')) + spec = Spec.from_file(os.path.join(CURRENT_DIR, "llvm.spec")) assert len(spec.patches_dict) == len(spec.patches) - assert spec.patches_dict['Patch0'] is spec.patches[0] + assert spec.patches_dict["Patch0"] is spec.patches[0] def test_subpackage_tags(self): - spec = Spec.from_file(os.path.join(CURRENT_DIR, 'jsrdbg.spec')) + spec = Spec.from_file(os.path.join(CURRENT_DIR, "jsrdbg.spec")) # Summary: tag - assert spec.summary == 'JavaScript Remote Debugger for SpiderMonkey' + assert spec.summary == "JavaScript Remote Debugger for SpiderMonkey" packages = spec.packages_dict - assert packages['jsrdbg-devel'].summary == \ - 'Header files, libraries and development documentation for %{name}' - assert packages['jrdb'].summary == 'A command line debugger client for %{name}' + assert ( + packages["jsrdbg-devel"].summary + == "Header files, libraries and development documentation for %{name}" + ) + assert packages["jrdb"].summary == "A command line debugger client for %{name}" def test_defines(self): - spec = Spec.from_file(os.path.join(CURRENT_DIR, 'attica-qt5.spec')) + spec = Spec.from_file(os.path.join(CURRENT_DIR, "attica-qt5.spec")) # Check if they exist - for define in ('sonum', '_tar_path', '_libname', 'rname'): + for define in ("sonum", "_tar_path", "_libname", "rname"): assert hasattr(spec, define) # Check values - assert spec.sonum == '5' - assert spec.rname == 'attica' - assert spec._libname == 'KF5Attica' - assert spec._tar_path == '5.31' + assert spec.sonum == "5" + assert spec.rname == "attica" + assert spec._libname == "KF5Attica" + assert spec._tar_path == "5.31" def test_requirement_parsing(self): - spec = Spec.from_file(os.path.join(CURRENT_DIR, 'attica-qt5.spec')) + spec = Spec.from_file(os.path.join(CURRENT_DIR, "attica-qt5.spec")) - assert spec.build_requires[0].name == 'cmake' - assert spec.build_requires[0].version == '3.0' - assert spec.build_requires[0].operator == '>=' + assert spec.build_requires[0].name == "cmake" + assert spec.build_requires[0].version == "3.0" + assert spec.build_requires[0].operator == ">=" def test_subpackage_has_requires(self): - spec = Spec.from_file(os.path.join(CURRENT_DIR, 'git.spec')) + spec = Spec.from_file(os.path.join(CURRENT_DIR, "git.spec")) - core_package = spec.packages_dict['git-core'] + core_package = spec.packages_dict["git-core"] assert len(core_package.requires) == 3 def test_subpackage_has_build_requires(self): @@ -131,14 +135,13 @@ sub-packages even though they might be empty. """ - spec = Spec.from_file(os.path.join(CURRENT_DIR, 'git.spec')) + spec = Spec.from_file(os.path.join(CURRENT_DIR, "git.spec")) - core_package = spec.packages_dict['git-core'] - assert len(core_package.build_requires) == 0 + core_package = spec.packages_dict["git-core"] + assert not core_package.build_requires class TestSpecClass: - def test_default_init(self): spec = Spec() assert spec.name is None @@ -160,62 +163,84 @@ class TestReplaceMacro: def test_replace_macro_with_spec(self): - spec = Spec.from_file(os.path.join(CURRENT_DIR, 'llvm.spec')) - assert 'http://llvm.org/releases/3.8.0/llvm-3.8.0.src.tar.xz' == replace_macros( - spec.sources[0], spec) - assert 'llvm-config.h' == replace_macros(spec.sources[1], spec) + spec = Spec.from_file(os.path.join(CURRENT_DIR, "llvm.spec")) + assert ( + replace_macros(spec.sources[0], spec) + == "http://llvm.org/releases/3.8.0/llvm-3.8.0.src.tar.xz" + ) + assert replace_macros(spec.sources[1], spec) == "llvm-config.h" def test_replace_without_spec(self): - s = 'http://llvm.org/releases/%{version}/%{name}-%{version}.src.tar.xz' + s = "http://llvm.org/releases/%{version}/%{name}-%{version}.src.tar.xz" assert s == replace_macros(s, spec=None) def test_replace_unknown_macro(self): - s = '%{foobar}' + s = "%{foobar}" assert s == replace_macros(s, spec=None) def test_replace_macro_int_type_val(self): - spec = Spec.from_file(os.path.join(CURRENT_DIR, 'perl-Array-Compare.spec')) - result = replace_macros('%{epoch}', spec) + spec = Spec.from_file(os.path.join(CURRENT_DIR, "perl-Array-Compare.spec")) + result = replace_macros("%{epoch}", spec) assert isinstance(result, str) def test_replace_macro_twice(self): - spec = Spec.from_file(os.path.join(CURRENT_DIR, 'jsrdbg.spec')) - assert 'https://github.com/swojtasiak/jsrdbg/archive/26f9f2b27c04b4aec9cd67baaf9a0a206bbbd5c7.tar.gz#/jsrdbg-26f9f2b27c04b4aec9cd67baaf9a0a206bbbd5c7.tar.gz' \ - == replace_macros(spec.sources[0], spec) + spec = Spec.from_file(os.path.join(CURRENT_DIR, "jsrdbg.spec")) + assert ( + replace_macros(spec.sources[0], spec) + == "https://github.com/swojtasiak/jsrdbg/archive/26f9f2b27c04b4aec9cd67baaf9a0a206bbbd5c7.tar.gz#/jsrdbg-26f9f2b27c04b4aec9cd67baaf9a0a206bbbd5c7.tar.gz" + ) def test_replace_user_defined_macro(self): - spec = Spec.from_string(""" + spec = Spec.from_string( + """ Name: foo Version: 2 %define var bar -""") - s = '%{name}/%{version}/%{var}' - assert 'foo/2/bar' == replace_macros(s, spec) +""" + ) + s = "%{name}/%{version}/%{var}" + assert replace_macros(s, spec) == "foo/2/bar" def test_replace_macro_with_negative_conditional(self): - spec = Spec.from_file(os.path.join(CURRENT_DIR, 'git.spec')) + spec = Spec.from_file(os.path.join(CURRENT_DIR, "git.spec")) - assert 'https://www.kernel.org/pub/software/scm/git/git-2.15.1.tar.xz' \ - == replace_macros( - 'https://www.kernel.org/pub/software/scm/git/%{?rcrev:testing/}%{name}-%{version}%{?rcrev}.tar.xz', spec) + assert ( + replace_macros( + "https://www.kernel.org/pub/software/scm/git/%{?rcrev:testing/}%{name}-%{version}%{?rcrev}.tar.xz", + spec, + ) + == "https://www.kernel.org/pub/software/scm/git/git-2.15.1.tar.xz" + ) def test_replace_macro_with_positive_conditional(self): - spec = Spec.from_string(""" + spec = Spec.from_string( + """ Name: git Version: 2.15.1 %define rcrev .rc0 - """) + """ + ) - assert 'https://www.kernel.org/pub/software/scm/git/testing/git-2.15.1.rc0.tar.xz' \ - == replace_macros( - 'https://www.kernel.org/pub/software/scm/git/%{?rcrev:testing/}%{name}-%{version}%{?rcrev}.tar.xz', spec) + assert ( + replace_macros( + "https://www.kernel.org/pub/software/scm/git/%{?rcrev:testing/}%{name}-%{version}%{?rcrev}.tar.xz", + spec, + ) + == "https://www.kernel.org/pub/software/scm/git/testing/git-2.15.1.rc0.tar.xz" + ) def test_replace_macro_with_leading_exclamation_point(self): - spec = Spec.from_string(""" + spec = Spec.from_string( + """ Name: git Version: 2.15.1 - """) + """ + ) - assert 'https://www.kernel.org/pub/software/scm/git/testing/git-2.15.1.tar.xz' \ - == replace_macros( - 'https://www.kernel.org/pub/software/scm/git/%{!stable:testing/}%{name}-%{version}.tar.xz', spec) + assert ( + replace_macros( + "https://www.kernel.org/pub/software/scm/git/%{!stable:testing/}%{name}-%{version}.tar.xz", + spec, + ) + == "https://www.kernel.org/pub/software/scm/git/testing/git-2.15.1.tar.xz" + )