Blob Blame History Raw
# Enabled by default
%bcond_without tests

# Sphinx-generated HTML documentation is not suitable for packaging; see
# for discussion.
# We can generate PDF documentation as a substitute.
%bcond_without doc_pdf

Name:           python-configupdater
Version:        3.1
Release:        %autorelease
Summary:        Parser like ConfigParser but for updating configuration files

License:        MIT
Source0:        %{pypi_source ConfigUpdater}

BuildArch:      noarch

%if %{with doc_pdf}
BuildRequires:  make
BuildRequires:  python3-sphinx-latex
BuildRequires:  latexmk

%global _description %{expand:
The sole purpose of ConfigUpdater is to easily update an INI config file with
no changes to the original file except the intended ones. This means comments,
the ordering of sections and key/value-pairs as well as their cases are kept as
in the original file. Thus ConfigUpdater provides complementary functionality
to Python’s ConfigParser which is primarily meant for reading config files and
writing new ones.


The key differences to ConfigParser are:

  • minimal invasive changes in the update configuration file,
  • proper handling of comments,
  • only a single config file can be updated at a time,
  • the original case of sections and keys are kept,
  • control over the position of a new section/key

The following features are deliberately not implemented:

  • interpolation of values,
  • propagation of parameters from the default section,
  • conversions of values,
  • passing key/value-pairs with default argument,
  • non-strict mode allowing duplicate sections and keys.}

%description %_description

%package -n python3-ConfigUpdater
Summary:        %{summary}
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
BuildRequires:  python3-setuptools_scm
BuildRequires:  %{py3_dist pytest}

%description -n python3-ConfigUpdater %_description

%package doc
Summary:        Documentation for %{name}

%description doc
This package provides generated documentation for %{name}.

%autosetup -n ConfigUpdater-%{version}

# Remove coverage bits
sed -i -r '/(--cov|pytest-cov)/ d' setup.cfg

# Drop intersphinx mappings, since we can’t download remote inventories and
# can’t easily produce working hyperlinks from inventories in local
# documentation packages.
echo 'intersphinx_mapping.clear()' >> docs/

%{pyproject_buildrequires \
    %{?with_tests:-x testing} %{?with_doc_pdf:docs/requirements.txt}}


%if %{with doc_pdf}
%make_build -C docs latex SPHINXOPTS='%{?_smp_mflags}'
%make_build -C docs/_build/latex LATEXMKOPTS='-quiet'

%pyproject_save_files configupdater

%if %{with tests}

%files -n python3-ConfigUpdater -f %{pyproject_files}
%license LICENSE.txt
%doc AUTHORS.rst
%doc CHANGELOG.rst
%doc README.rst

%files doc
%license LICENSE.txt
%if %{with doc_pdf}
%doc docs/_build/latex/user_guide.pdf