From ce606f1d9f78f984e65697bf1c4c6d186798b6ce Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Wed, 17 Oct 2018 15:02:57 +0200 Subject: [PATCH] import of template project --- .gitignore | 1 + Makefile | 71 ++++++++++++++++++++++++++++++++++++++++++ Pipfile | 11 +++++++ requirements_dev.txt | 10 ++++++ s2rename/__init__.py | 7 +++++ s2rename/cli.py | 18 +++++++++++ s2rename/s2rename.py | 3 ++ setup.cfg | 26 ++++++++++++++++ setup.py | 53 +++++++++++++++++++++++++++++++ tests/test_s2rename.py | 38 ++++++++++++++++++++++ 10 files changed, 238 insertions(+) create mode 100644 Makefile create mode 100644 Pipfile create mode 100644 requirements_dev.txt create mode 100644 s2rename/__init__.py create mode 100644 s2rename/cli.py create mode 100644 s2rename/s2rename.py create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 tests/test_s2rename.py diff --git a/.gitignore b/.gitignore index 7f7cccc..bc2ca22 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ var/ *.egg-info/ .installed.cfg *.egg +.venv # PyInstaller # Usually these files are written by a python script from a template diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0699ddf --- /dev/null +++ b/Makefile @@ -0,0 +1,71 @@ +.PHONY: clean clean-test clean-pyc clean-build docs help +.DEFAULT_GOAL := help + +define BROWSER_PYSCRIPT +import os, webbrowser, sys + +try: + from urllib import pathname2url +except: + from urllib.request import pathname2url + +webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) +endef +export BROWSER_PYSCRIPT + +define PRINT_HELP_PYSCRIPT +import re, sys + +for line in sys.stdin: + match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) + if match: + target, help = match.groups() + print("%-20s %s" % (target, help)) +endef +export PRINT_HELP_PYSCRIPT + +BROWSER := python -c "$$BROWSER_PYSCRIPT" + +help: + @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) + +clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts + +clean-build: ## remove build artifacts + rm -fr build/ + rm -fr dist/ + rm -fr .eggs/ + find . -name '*.egg-info' -exec rm -fr {} + + find . -name '*.egg' -exec rm -f {} + + +clean-pyc: ## remove Python file artifacts + find . -name '*.pyc' -exec rm -f {} + + find . -name '*.pyo' -exec rm -f {} + + find . -name '*~' -exec rm -f {} + + find . -name '__pycache__' -exec rm -fr {} + + +clean-test: ## remove test and coverage artifacts + rm -fr .tox/ + rm -f .coverage + rm -fr htmlcov/ + rm -fr .pytest_cache + +lint: ## check style with flake8 + flake8 s2rename tests + +test: ## run tests quickly with the default Python + py.test + +coverage: ## check code coverage quickly with the default Python + coverage run --source s2rename -m pytest + coverage report -m + coverage html + $(BROWSER) htmlcov/index.html + +dist: clean ## builds source and wheel package + python setup.py sdist + python setup.py bdist_wheel + ls -l dist + +install: clean ## install the package to the active Python's site-packages + python setup.py install diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..b9ba84f --- /dev/null +++ b/Pipfile @@ -0,0 +1,11 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] + +[dev-packages] + +[requires] +python_version = "3.7" diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000..41d51f6 --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,10 @@ +pip==18.1 +bumpversion==0.5.3 +wheel==0.32.1 +watchdog==0.9.0 +flake8==3.5.0 +coverage==4.5.1 +black>=18.9 + +pytest==3.8.2 +pytest-runner==4.2 diff --git a/s2rename/__init__.py b/s2rename/__init__.py new file mode 100644 index 0000000..55ec5d3 --- /dev/null +++ b/s2rename/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- + +"""Top-level package for S2Rename.""" + +__author__ = """Holger Frey""" +__email__ = 'frey@imtek.de' +__version__ = '0.0.1' diff --git a/s2rename/cli.py b/s2rename/cli.py new file mode 100644 index 0000000..5276f59 --- /dev/null +++ b/s2rename/cli.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +"""Console script for s2rename.""" +import sys +import click + + +@click.command() +def main(args=None): + """Console script for s2rename.""" + click.echo("Replace this message by putting your code into " + "s2rename.cli.main") + click.echo("See click documentation at http://click.pocoo.org/") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) # pragma: no cover diff --git a/s2rename/s2rename.py b/s2rename/s2rename.py new file mode 100644 index 0000000..7fbbae4 --- /dev/null +++ b/s2rename/s2rename.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +"""Main module.""" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..5c4fd98 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,26 @@ +[bumpversion] +current_version = 0.0.1 +commit = True +tag = True + +[bumpversion:file:setup.py] +search = version='{current_version}' +replace = version='{new_version}' + +[bumpversion:file:s2rename/__init__.py] +search = __version__ = '{current_version}' +replace = __version__ = '{new_version}' + +[bdist_wheel] +universal = 1 + +[flake8] +exclude = docs + +[aliases] +# Define setup.py command aliases here +test = pytest + +[tool:pytest] +collect_ignore = ['setup.py'] + diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..c22a1c0 --- /dev/null +++ b/setup.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +"""The setup script.""" + +from setuptools import setup, find_packages + +with open('README.rst') as readme_file: + readme = readme_file.read() + +with open('HISTORY.rst') as history_file: + history = history_file.read() + +requirements = ['Click>=6.0', ] + +setup_requirements = ['pytest-runner', ] + +test_requirements = ['pytest', ] + +setup( + author="Holger Frey", + author_email='frey@imtek.de', + classifiers=[ + 'Development Status :: 2 - Pre-Alpha', + 'Intended Audience :: Developers', + 'Natural Language :: English', + "Programming Language :: Python :: 2", + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + ], + description="Renaming files for SensoSpot and Scienion software", + entry_points={ + 'console_scripts': [ + 's2rename=s2rename.cli:main', + ], + }, + install_requires=requirements, + long_description=readme + '\n\n' + history, + include_package_data=True, + keywords='s2rename', + name='s2rename', + packages=find_packages(include=['s2rename']), + setup_requires=setup_requirements, + test_suite='tests', + tests_require=test_requirements, + url='https://github.com/audreyr/s2rename', + version='0.0.1', + zip_safe=False, +) diff --git a/tests/test_s2rename.py b/tests/test_s2rename.py new file mode 100644 index 0000000..01870d5 --- /dev/null +++ b/tests/test_s2rename.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +"""Tests for `s2rename` package.""" + +import pytest + +from click.testing import CliRunner + +from s2rename import s2rename +from s2rename import cli + + +@pytest.fixture +def response(): + """Sample pytest fixture. + + See more at: http://doc.pytest.org/en/latest/fixture.html + """ + # import requests + # return requests.get('https://github.com/audreyr/cookiecutter-pypackage') + + +def test_content(response): + """Sample pytest test function with the pytest fixture as an argument.""" + # from bs4 import BeautifulSoup + # assert 'GitHub' in BeautifulSoup(response.content).title.string + + +def test_command_line_interface(): + """Test the CLI.""" + runner = CliRunner() + result = runner.invoke(cli.main) + assert result.exit_code == 0 + assert 's2rename.cli.main' in result.output + help_result = runner.invoke(cli.main, ['--help']) + assert help_result.exit_code == 0 + assert '--help Show this message and exit.' in help_result.output