Browse Source

import of template project

master
Holger Frey 6 years ago
parent
commit
ce606f1d9f
  1. 1
      .gitignore
  2. 71
      Makefile
  3. 11
      Pipfile
  4. 10
      requirements_dev.txt
  5. 7
      s2rename/__init__.py
  6. 18
      s2rename/cli.py
  7. 3
      s2rename/s2rename.py
  8. 26
      setup.cfg
  9. 53
      setup.py
  10. 38
      tests/test_s2rename.py

1
.gitignore vendored

@ -24,6 +24,7 @@ var/
*.egg-info/ *.egg-info/
.installed.cfg .installed.cfg
*.egg *.egg
.venv
# PyInstaller # PyInstaller
# Usually these files are written by a python script from a template # Usually these files are written by a python script from a template

71
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

11
Pipfile

@ -0,0 +1,11 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
[dev-packages]
[requires]
python_version = "3.7"

10
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

7
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'

18
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

3
s2rename/s2rename.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
"""Main module."""

26
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']

53
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,
)

38
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