Metadata-Version: 2.4
Name: spec_cleaner
Version: 1.3.1
Summary: RPM .spec files cleaner
Author-email: Kristyna Streitova <kstreitova@suse.com>, Tomáš Chvátal <tchvatal@suse.com>
License-Expression: BSD-3-Clause
Project-URL: Homepage, https://github.com/rpm-software-management/spec-cleaner
Project-URL: Repository, https://github.com/rpm-software-management/spec-cleaner.git
Project-URL: Issues, https://github.com/rpm-software-management/spec-cleaner/issues
Project-URL: Changelog, https://github.com/rpm-software-management/spec-cleaner/releases
Keywords: SUSE,RPM,.spec,cleaner
Platform: Linux
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Operating System :: Unix
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Utilities
Classifier: Topic :: Text Processing
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: COPYING
License-File: AUTHORS
Requires-Dist: python-rpm-spec
Provides-Extra: tests
Requires-Dist: pytest; extra == "tests"
Requires-Dist: pytest-cov; extra == "tests"
Requires-Dist: pytest-xdist; extra == "tests"
Dynamic: license-file


# spec-cleaner

<img src="https://raw.githubusercontent.com/rpm-software-management/spec-cleaner/master/docs/assets/logo.svg"
     align="right" width="130" alt="spec-cleaner logo">

![Build Status](https://github.com/rpm-software-management/spec-cleaner/actions/workflows/pythonpackage.yml/badge.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/rpm-software-management/spec-cleaner/badge.svg?branch=master)](https://coveralls.io/github/rpm-software-management/spec-cleaner?branch=master)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)


spec-cleaner is a tool that cleans the given RPM spec file according to the style guide and returns the result.

It's used for [openSUSE](https://www.opensuse.org), where it's planned to be a replacement for `osc service localrun format_spec_file` and it is intended to provide the same or better features in order to be able to unify all the spec files in [OBS](https://build.opensuse.org/).

# Table of contents
* [Installation and usage](#installation-and-usage)
* [Tests](#tests)
* [Contributing](#contributing)
* [Versioning and releasing](#versioning-and-releasing)
* [Authors](#authors)

## Installation and usage

### Installation
The latest version is available on [PyPI](https://pypi.org/project/spec_cleaner/). It can be installed by running `pip install spec_cleaner`.

spec-cleaner is also provided as an RPM package for openSUSE Tumbleweed ([openSUSE:Factory](https://build.opensuse.org/package/show/openSUSE:Factory/spec-cleaner)) and all maintained openSUSE Leap codestreams. When a new version of spec-cleaner is released, updates are submitted for all maintained codestreams.

### Usage
Simply run `spec-cleaner -i <specfile>` to clean your specfile up.

License conversions come from [SPDX data](https://spdx.org/licenses/) plus SUSE additions; the full tag list is in [SPDX-LICENSES.md](SPDX-LICENSES.md).


## Tests

### Running the tests
spec-cleaner provides quite an extensive testsuite. You can run these tests locally directly via `pytest`.

#### pytest
Just install `python3-pytest`, `python3-pytest-cov` and `python3-pytest-sugar` (for a nice progress bar) and then run all tests via:

    pytest

## Contributing
You are more than welcome to contribute to this project. If you are not sure about your changes, feel free to create an issue where you can discuss it before the implementation.

### Contribution Guidelines

When changing anything in the code, make sure that you don't forget to:

  * Follow [pep8](https://www.python.org/dev/peps/pep-0008/).
  * Install [pre-commit](https://pre-commit.com/) framework and run `pre-commit install` to install `pre-commit` into your git hooks.
  * Add proper comments and docstrings (follow [pep257](https://www.python.org/dev/peps/pep-0257/) and [Google Python Style Guide for docstrings and comments](http://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings))
  * Add [tests](TESTSUITE.md) (mainly if you implement a new feature).
  * Add `mypy` support for the new code.
  * Run and pass all tests, `ruff` and `mypy` checks.

See below for more details.

### pre-commit

spec-cleaner project adopted `pre-commit` framework for managing and maintaining pre-commit hooks. After you clone the spec-cleaner repository, please install [pre-commit](https://pre-commit.com/) framework (`pip install pre-commit`) and run `pre-commit install` to install `pre-commit` into your git hooks. Then `pre-commit` will run automatically on `git commit` and it will check your contribution with `ruff` and `mypy`.

Please note that similar checks run in CI when you submit a PR and it won't pass code review without passing these checks.

### mypy

Optional static type checker support was implemented for the most important parts of the code. If you want to run it on your own, just install `python3-mypy` and run

     mypy spec_cleaner

### Ruff

The code of spec-cleaner is formatted with [Ruff](https://github.com/astral-sh/ruff). We use single quotes and `--line-length 100`. Ruff runs automatically in the `pre-commit` hook and is enforced in CI.

### Adding new tests
When a new feature is added to spec-cleaner then a test for this piece of code must be added. See [how to write tests for spec-cleaner](TESTSUITE.md).


## Versioning and releasing
For the versions available, see the [tags on this repository](https://github.com/rpm-software-management/spec-cleaner/releases).

If you have proper permissions you can find handy [how to do a new release](RELEASE.md).

## Authors

* See the list of [contributors](AUTHORS) who participated in this project

