Skip to content

Commit

Permalink
feat. Adds support for PyPi. Closes #8.
Browse files Browse the repository at this point in the history
  • Loading branch information
tamere-allo-peter committed Mar 15, 2022
1 parent 79bba2d commit 8fb6519
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 14 deletions.
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include requirements.txt
include Dockerfile
recursive-include examples/ *.yml *.yaml
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ in your `$PATH` :
- [x] `Python v3.6` (or higher)
- [x] `yamllint v1.26.3` (or higher)

Then simply copy the `yamlfixer` file to a directory present in your
`$PATH`, and ensure it is executable, for example:
Then simply install `yamlfixer` from [pypi](https://pypi.org/)

```shell
cp yamlfixer /usr/local/bin
chmod 0755 /usr/local/bin/yamlfixer
python3 -m pip install yamlfixer-opt-nc
```


Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
42 changes: 42 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[metadata]
version = 0.3.0
name = yamlfixer-opt-nc
description = automates the fixing of problems reported by yamllint
long_description = file: README.md
author = "OPT-NC"
author_email = "[email protected]"
license = "GPLv3+"
license_file = LICENSE
long_description_content_type = text/markdown
url = https://github.com/opt-nc/yamlfixer
project_urls =
Bug Tracker = https://github.com/opt-nc/yamlfixer/issues
Releases = https://github.com/opt-nc/yamlfixer/releases
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Operating System :: OS Independent
Environment :: Console
Topic :: Utilities
Topic :: Text Processing
Development Status :: 5 - Production/Stable
Intended Audience :: System Administrators
Intended Audience :: Developers
Natural Language :: English


[options]
packages = find:
python_requires = >=3.6
include_package_data = True
install_requires =
yamllint >= 1.26.3
setuptools

[options.package_data]
yamlfixer = examples/*.yaml examples/*.yml

[options.entry_points]
console_scripts =
yamlfixer = yamlfixer:run

21 changes: 11 additions & 10 deletions yamlfixer → yamlfixer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

"""yamlfixer automates the fixing of problems reported by yamllint
by feeding it with files and parsing its output."""

import sys
import os
import time
import subprocess
import argparse
import json

VERSION = '0.2.0'
GPLBLURB = """Copyright (C) 2021-2022 OPT-NC
__version__ = "0.3.0"
__author__ = "OPT-NC"
__license__ = "GPLv3+"
__copyright__ = "Copyright (C) 2021-%s %s" % (time.strftime("%Y",
time.localtime(time.time())),
__author__)

GPLBLURB = """
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
Expand Down Expand Up @@ -467,7 +472,7 @@ def fix(self):
return EXIT_NOK


def main():
def run():
"""Main function."""
# Ensure we read from stdin in case it's redirected
if ("-" not in sys.argv[1:]) and not sys.stdin.isatty():
Expand All @@ -476,11 +481,11 @@ def main():
# Parse the command line arguments
cmdline = argparse.ArgumentParser(description="Fix formatting problems in YAML documents. "
"If no file is specified,\nthen reads input from `stdin`.",
epilog=GPLBLURB,
epilog=f"{__copyright__}\n{GPLBLURB}",
formatter_class=argparse.RawDescriptionHelpFormatter)
cmdline.add_argument("-v", "--version",
action="version",
version=f"yamlfixer v{VERSION}",
version=f"yamlfixer v{__version__}",
help="display this program's version number")
cmdline.add_argument("-b", "--backup",
action="store_true",
Expand All @@ -502,7 +507,3 @@ def main():
help="the YAML files to fix. Use `-` to read from `stdin`.")
arguments = cmdline.parse_args()
return YAMLFixer(arguments).fix()


if __name__ == '__main__':
sys.exit(main())
6 changes: 6 additions & 0 deletions yamlfixer/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-

from . import run

if __name__ == '__main__':
sys.exit(run())

0 comments on commit 8fb6519

Please sign in to comment.