From 2997331fc42dfe482daf826d869012ef11e9ea8c Mon Sep 17 00:00:00 2001 From: bpaulin Date: Fri, 15 Feb 2019 20:33:14 +0100 Subject: [PATCH] cookie --- .editorconfig | 21 +++++ .github/ISSUE_TEMPLATE.md | 15 +++ .gitignore | 22 +---- .travis.yml | 28 +++--- AUTHORS.rst | 13 +++ CONTRIBUTING.rst | 128 ++++++++++++++++++++++++++ HISTORY.rst | 8 ++ LICENSE | 22 +++++ MANIFEST | 7 -- MANIFEST.in | 11 +++ Makefile | 88 ++++++++++++++++++ README.md | 22 ----- README.rst | 41 +++++++++ bin/brownpaperbag | 24 ----- brownpaperbag/__init__.py | 10 +- brownpaperbag/brownpaperbag.py | 3 + brownpaperbag/cli.py | 18 ++++ docs/Makefile | 20 ++++ docs/authors.rst | 1 + docs/conf.py | 163 +++++++++++++++++++++++++++++++++ docs/contributing.rst | 1 + docs/history.rst | 1 + docs/index.rst | 20 ++++ docs/installation.rst | 51 +++++++++++ docs/make.bat | 36 ++++++++ docs/readme.rst | 1 + docs/usage.rst | 7 ++ requirements-dev.txt | 2 - requirements-lint.txt | 8 -- requirements_dev.txt | 12 +++ setup.cfg | 28 +++++- setup.py | 63 ++++++++++--- tests/test_brownpaperbag.py | 38 ++++++++ tox.ini | 32 ++++--- 34 files changed, 842 insertions(+), 123 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 AUTHORS.rst create mode 100644 CONTRIBUTING.rst create mode 100644 HISTORY.rst create mode 100644 LICENSE delete mode 100644 MANIFEST create mode 100644 MANIFEST.in create mode 100644 Makefile delete mode 100644 README.md create mode 100644 README.rst delete mode 100644 bin/brownpaperbag create mode 100644 brownpaperbag/brownpaperbag.py create mode 100644 brownpaperbag/cli.py create mode 100644 docs/Makefile create mode 100644 docs/authors.rst create mode 100755 docs/conf.py create mode 100644 docs/contributing.rst create mode 100644 docs/history.rst create mode 100644 docs/index.rst create mode 100644 docs/installation.rst create mode 100644 docs/make.bat create mode 100644 docs/readme.rst create mode 100644 docs/usage.rst delete mode 100644 requirements-dev.txt delete mode 100644 requirements-lint.txt create mode 100644 requirements_dev.txt create mode 100644 tests/test_brownpaperbag.py diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d4a2c44 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# http://editorconfig.org + +root = true + +[*] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true +charset = utf-8 +end_of_line = lf + +[*.bat] +indent_style = tab +end_of_line = crlf + +[LICENSE] +insert_final_newline = false + +[Makefile] +indent_style = tab diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..4978e63 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,15 @@ +* brownpaperbag version: +* Python version: +* Operating System: + +### Description + +Describe what you were trying to get done. +Tell us what happened, what went wrong, and what you expected to happen. + +### What I Did + +``` +Paste the command(s) you ran and the output. +If there was a crash, please include the traceback here. +``` diff --git a/.gitignore b/.gitignore index 9bce9eb..e48fb44 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ __pycache__/ # Distribution / packaging .Python +env/ build/ develop-eggs/ dist/ @@ -20,12 +21,9 @@ parts/ sdist/ var/ wheels/ -pip-wheel-metadata/ -share/python-wheels/ *.egg-info/ .installed.cfg *.egg -MANIFEST # PyInstaller # Usually these files are written by a python script from a template @@ -40,7 +38,6 @@ pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ -.nox/ .coverage .coverage.* .cache @@ -57,7 +54,6 @@ coverage.xml # Django stuff: *.log local_settings.py -db.sqlite3 # Flask stuff: instance/ @@ -75,10 +71,6 @@ target/ # Jupyter Notebook .ipynb_checkpoints -# IPython -profile_default/ -ipython_config.py - # pyenv .python-version @@ -88,14 +80,13 @@ celerybeat-schedule # SageMath parsed files *.sage.py -# Environments +# dotenv .env + +# virtualenv .venv -env/ venv/ ENV/ -env.bak/ -venv.bak/ # Spyder project settings .spyderproject @@ -109,8 +100,5 @@ venv.bak/ # mypy .mypy_cache/ -.dmypy.json -dmypy.json -# Pyre type checker -.pyre/ \ No newline at end of file +.idea/ diff --git a/.travis.yml b/.travis.yml index 74568d9..2330a1e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,17 @@ -sudo: true -dist: xenial language: python -matrix: - include: - - python: 3.5 - - python: 3.6 - - python: 3.7 - - python: 3.7 - env: TOXENV=flake8 - -install: pip install tox-travis -script: tox \ No newline at end of file +python: +- 3.6 +- 3.5 +- 3.4 +install: pip install -U tox-travis +script: tox +deploy: + provider: pypi + distributions: sdist bdist_wheel + user: bpaulin + password: + secure: f2D/tVQTIup6vfEnmOjewsAW12vvvtreIFLodK/6DrcTY5cEai6zme1gJn1T790cAPLarArDV9mjJcizXBUDyF8okaLnotv6Q+pErgBwjLD+KmcQXCrcW5DbNHO+5rJAZWgy1cDmuVdwqTA2ecNB5O/APOIQ9wAmCjvo2vDZ2g9WFO+FqPw6sm5kGZMPcPY9jS857J9k9aSMb2FrZ6TIhnMKwR15FxLBbBt1MaXJa9WyM0dHLDWH1FoIwfAgGzAd/EaHcoTM3Zd9GLtrkO3Phn5AbGuHNRd0gpAeGWFmt88uooisPChUWYBjgdFJMjB/VVsKms1VSW0dJD89S/SmJ9IQYdIkJAvC0F4vUNa23XBjNztnE0wEn3j6cI3IsSb48VZ6yXbYRjsqYdlp8gw79jFHrp/Cnppvx5/GR6FfmErza9xBJPyaJZbFTyQdhLfOR1SmU8gBRClLMnaPe7TWjQFhtagYlz9undaOdouSv9B+XB1T60QUhsMEsSocC7eY+WxBojm1Ek8itb4t5kpspTaVXw7FYyMGCyX4J2IK42SGf1J1OCxZIaagxv4DL9AfQIWsccoSYmnw0ZjIAMIO0483CMfDafnuhHkqb4Kr8ihwfG5tstSOddc0WtVDynfjpO/+61QwyS+3aHgOweBeOlHf2Rvql4B1e1BIL+P6hsw= + on: + tags: true + repo: bpaulin/brownpaperbag + python: 3.6 diff --git a/AUTHORS.rst b/AUTHORS.rst new file mode 100644 index 0000000..5c37e18 --- /dev/null +++ b/AUTHORS.rst @@ -0,0 +1,13 @@ +======= +Credits +======= + +Development Lead +---------------- + +* Bruno Paulin + +Contributors +------------ + +None yet. Why not be the first? diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 0000000..d2e94f7 --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,128 @@ +.. highlight:: shell + +============ +Contributing +============ + +Contributions are welcome, and they are greatly appreciated! Every little bit +helps, and credit will always be given. + +You can contribute in many ways: + +Types of Contributions +---------------------- + +Report Bugs +~~~~~~~~~~~ + +Report bugs at https://github.com/bpaulin/brownpaperbag/issues. + +If you are reporting a bug, please include: + +* Your operating system name and version. +* Any details about your local setup that might be helpful in troubleshooting. +* Detailed steps to reproduce the bug. + +Fix Bugs +~~~~~~~~ + +Look through the GitHub issues for bugs. Anything tagged with "bug" and "help +wanted" is open to whoever wants to implement it. + +Implement Features +~~~~~~~~~~~~~~~~~~ + +Look through the GitHub issues for features. Anything tagged with "enhancement" +and "help wanted" is open to whoever wants to implement it. + +Write Documentation +~~~~~~~~~~~~~~~~~~~ + +brownpaperbag could always use more documentation, whether as part of the +official brownpaperbag docs, in docstrings, or even on the web in blog posts, +articles, and such. + +Submit Feedback +~~~~~~~~~~~~~~~ + +The best way to send feedback is to file an issue at https://github.com/bpaulin/brownpaperbag/issues. + +If you are proposing a feature: + +* Explain in detail how it would work. +* Keep the scope as narrow as possible, to make it easier to implement. +* Remember that this is a volunteer-driven project, and that contributions + are welcome :) + +Get Started! +------------ + +Ready to contribute? Here's how to set up `brownpaperbag` for local development. + +1. Fork the `brownpaperbag` repo on GitHub. +2. Clone your fork locally:: + + $ git clone git@github.com:your_name_here/brownpaperbag.git + +3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: + + $ mkvirtualenv brownpaperbag + $ cd brownpaperbag/ + $ python setup.py develop + +4. Create a branch for local development:: + + $ git checkout -b name-of-your-bugfix-or-feature + + Now you can make your changes locally. + +5. When you're done making changes, check that your changes pass flake8 and the + tests, including testing other Python versions with tox:: + + $ flake8 brownpaperbag tests + $ python setup.py test or py.test + $ tox + + To get flake8 and tox, just pip install them into your virtualenv. + +6. Commit your changes and push your branch to GitHub:: + + $ git add . + $ git commit -m "Your detailed description of your changes." + $ git push origin name-of-your-bugfix-or-feature + +7. Submit a pull request through the GitHub website. + +Pull Request Guidelines +----------------------- + +Before you submit a pull request, check that it meets these guidelines: + +1. The pull request should include tests. +2. If the pull request adds functionality, the docs should be updated. Put + your new functionality into a function with a docstring, and add the + feature to the list in README.rst. +3. The pull request should work for Python 2.7, 3.4, 3.5 and 3.6, and for PyPy. Check + https://travis-ci.org/bpaulin/brownpaperbag/pull_requests + and make sure that the tests pass for all supported Python versions. + +Tips +---- + +To run a subset of tests:: + +$ py.test tests.test_brownpaperbag + + +Deploying +--------- + +A reminder for the maintainers on how to deploy. +Make sure all your changes are committed (including an entry in HISTORY.rst). +Then run:: + +$ bumpversion patch # possible: major / minor / patch +$ git push +$ git push --tags + +Travis will then deploy to PyPI if tests pass. diff --git a/HISTORY.rst b/HISTORY.rst new file mode 100644 index 0000000..034bc54 --- /dev/null +++ b/HISTORY.rst @@ -0,0 +1,8 @@ +======= +History +======= + +0.0.5 (2019-02-15) +------------------ + +* First release on PyPI. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..97de7bd --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2019, Bruno Paulin + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/MANIFEST b/MANIFEST deleted file mode 100644 index f898fa8..0000000 --- a/MANIFEST +++ /dev/null @@ -1,7 +0,0 @@ -# file GENERATED by distutils, do NOT edit -setup.cfg -setup.py -bin/brownpaperbag -brownpaperbag/__init__.py -brownpaperbag/authent.py -brownpaperbag/bpbgate.py diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..965b2dd --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,11 @@ +include AUTHORS.rst +include CONTRIBUTING.rst +include HISTORY.rst +include LICENSE +include README.rst + +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] + +recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ceea3a5 --- /dev/null +++ b/Makefile @@ -0,0 +1,88 @@ +.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 brownpaperbag tests + +test: ## run tests quickly with the default Python + py.test + +test-all: ## run tests on every Python version with tox + tox + +coverage: ## check code coverage quickly with the default Python + coverage run --source brownpaperbag -m pytest + coverage report -m + coverage html + $(BROWSER) htmlcov/index.html + +docs: ## generate Sphinx HTML documentation, including API docs + rm -f docs/brownpaperbag.rst + rm -f docs/modules.rst + sphinx-apidoc -o docs/ brownpaperbag + $(MAKE) -C docs clean + $(MAKE) -C docs html + $(BROWSER) docs/_build/html/index.html + +servedocs: docs ## compile the docs watching for changes + watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . + +release: dist ## package and upload a release + twine upload dist/* + +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/README.md b/README.md deleted file mode 100644 index a2aee06..0000000 --- a/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# brown paper bag - -python package to communicate with myHomeServer1 (legrand/bticino) using openwebnet protocol - -## brown paper what? - -because You were lucky to have a [ROOM](https://www.youtube.com/watch?v=ue7wM0QC5LE)! *We* used to have to live in a [corridor](http://www.montypython.net/scripts/4york.php)! - -## how to use -```python -from brownpaperbag.bpbgate import BpbGate - -gate = BpbGate("192.168.1.1300", 20000, 'azerty123') - -lights = gate.get_light_ids() # return list of every light -gate.turn_on_light('01') # turn on light #01 -gate.turn_off_light('01') # turn off light #01 -gate.is_light_on('01') # return true if light #01 is on -``` - -homeassistant/light/bticino/01/config -{"name": "prise", "command_topic": "bticino/1/01/set", "payload_on": "1", "payload_off": "0", "state_topic":"bticino/1/01"} \ No newline at end of file diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..7062dee --- /dev/null +++ b/README.rst @@ -0,0 +1,41 @@ +============= +brownpaperbag +============= + + +.. image:: https://img.shields.io/pypi/v/brownpaperbag.svg + :target: https://pypi.python.org/pypi/brownpaperbag + +.. image:: https://img.shields.io/travis/bpaulin/brownpaperbag.svg + :target: https://travis-ci.org/bpaulin/brownpaperbag + +.. image:: https://readthedocs.org/projects/brownpaperbag/badge/?version=latest + :target: https://brownpaperbag.readthedocs.io/en/latest/?badge=latest + :alt: Documentation Status + + +.. image:: https://pyup.io/repos/github/bpaulin/brownpaperbag/shield.svg + :target: https://pyup.io/repos/github/bpaulin/brownpaperbag/ + :alt: Updates + + + +But you try and tell the young people today that... + + +* Free software: MIT license +* Documentation: https://brownpaperbag.readthedocs.io. + + +Features +-------- + +* TODO + +Credits +------- + +This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. + +.. _Cookiecutter: https://github.com/audreyr/cookiecutter +.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage diff --git a/bin/brownpaperbag b/bin/brownpaperbag deleted file mode 100644 index 0f31c38..0000000 --- a/bin/brownpaperbag +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python - -import logging -import argparse -import asyncio - -from brownpaperbag import BpbGate - -parser = argparse.ArgumentParser() - -parser.add_argument("-v", "--verbose", - action="store_true") -parser.add_argument("host") -parser.add_argument("port") -parser.add_argument("password") -args = parser.parse_args() -level = logging.INFO -if args.verbose: - level = logging.DEBUG -logging.basicConfig(format="%(levelname)s: %(message)s", level=level) - -gate = BpbGate(args.host, args.port, args.password) -gate.logger = logging -print(asyncio.run(gate.is_light_on('0111'))) diff --git a/brownpaperbag/__init__.py b/brownpaperbag/__init__.py index 8a844b2..6d3d9a8 100644 --- a/brownpaperbag/__init__.py +++ b/brownpaperbag/__init__.py @@ -1,3 +1,7 @@ -"""BrownPaperBag.""" -# flake8: noqa -from .bpbgate import BpbGate, SESSION_EVENT +# -*- coding: utf-8 -*- + +"""Top-level package for brownpaperbag.""" + +__author__ = """Bruno Paulin""" +__email__ = 'brunopaulin@bpaulin.net' +__version__ = '0.0.5' diff --git a/brownpaperbag/brownpaperbag.py b/brownpaperbag/brownpaperbag.py new file mode 100644 index 0000000..7fbbae4 --- /dev/null +++ b/brownpaperbag/brownpaperbag.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +"""Main module.""" diff --git a/brownpaperbag/cli.py b/brownpaperbag/cli.py new file mode 100644 index 0000000..cb15b11 --- /dev/null +++ b/brownpaperbag/cli.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +"""Console script for brownpaperbag.""" +import sys +import click + + +@click.command() +def main(args=None): + """Console script for brownpaperbag.""" + click.echo("Replace this message by putting your code into " + "brownpaperbag.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/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..7b3faed --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = python -msphinx +SPHINXPROJ = brownpaperbag +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/authors.rst b/docs/authors.rst new file mode 100644 index 0000000..e122f91 --- /dev/null +++ b/docs/authors.rst @@ -0,0 +1 @@ +.. include:: ../AUTHORS.rst diff --git a/docs/conf.py b/docs/conf.py new file mode 100755 index 0000000..7ffb802 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,163 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# brownpaperbag documentation build configuration file, created by +# sphinx-quickstart on Fri Jun 9 13:47:02 2017. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +# If extensions (or modules to document with autodoc) are in another +# directory, add these directories to sys.path here. If the directory is +# relative to the documentation root, use os.path.abspath to make it +# absolute, like shown here. +# +import os +import sys +sys.path.insert(0, os.path.abspath('..')) + +import brownpaperbag + +# -- General configuration --------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'brownpaperbag' +copyright = u"2019, Bruno Paulin" +author = u"Bruno Paulin" + +# The version info for the project you're documenting, acts as replacement +# for |version| and |release|, also used in various other places throughout +# the built documents. +# +# The short X.Y version. +version = brownpaperbag.__version__ +# The full version, including alpha/beta/rc tags. +release = brownpaperbag.__version__ + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This patterns also effect to html_static_path and html_extra_path +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = False + + +# -- Options for HTML output ------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a +# theme further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + + +# -- Options for HTMLHelp output --------------------------------------- + +# Output file base name for HTML help builder. +htmlhelp_basename = 'brownpaperbagdoc' + + +# -- Options for LaTeX output ------------------------------------------ + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass +# [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'brownpaperbag.tex', + u'brownpaperbag Documentation', + u'Bruno Paulin', 'manual'), +] + + +# -- Options for manual page output ------------------------------------ + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'brownpaperbag', + u'brownpaperbag Documentation', + [author], 1) +] + + +# -- Options for Texinfo output ---------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'brownpaperbag', + u'brownpaperbag Documentation', + author, + 'brownpaperbag', + 'One line description of project.', + 'Miscellaneous'), +] + + + diff --git a/docs/contributing.rst b/docs/contributing.rst new file mode 100644 index 0000000..e582053 --- /dev/null +++ b/docs/contributing.rst @@ -0,0 +1 @@ +.. include:: ../CONTRIBUTING.rst diff --git a/docs/history.rst b/docs/history.rst new file mode 100644 index 0000000..2506499 --- /dev/null +++ b/docs/history.rst @@ -0,0 +1 @@ +.. include:: ../HISTORY.rst diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..dff2901 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,20 @@ +Welcome to brownpaperbag's documentation! +====================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + readme + installation + usage + modules + contributing + authors + history + +Indices and tables +================== +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/installation.rst b/docs/installation.rst new file mode 100644 index 0000000..ef3da82 --- /dev/null +++ b/docs/installation.rst @@ -0,0 +1,51 @@ +.. highlight:: shell + +============ +Installation +============ + + +Stable release +-------------- + +To install brownpaperbag, run this command in your terminal: + +.. code-block:: console + + $ pip install brownpaperbag + +This is the preferred method to install brownpaperbag, as it will always install the most recent stable release. + +If you don't have `pip`_ installed, this `Python installation guide`_ can guide +you through the process. + +.. _pip: https://pip.pypa.io +.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ + + +From sources +------------ + +The sources for brownpaperbag can be downloaded from the `Github repo`_. + +You can either clone the public repository: + +.. code-block:: console + + $ git clone git://github.com/bpaulin/brownpaperbag + +Or download the `tarball`_: + +.. code-block:: console + + $ curl -OL https://github.com/bpaulin/brownpaperbag/tarball/master + +Once you have a copy of the source, you can install it with: + +.. code-block:: console + + $ python setup.py install + + +.. _Github repo: https://github.com/bpaulin/brownpaperbag +.. _tarball: https://github.com/bpaulin/brownpaperbag/tarball/master diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..bdbea41 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,36 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=python -msphinx +) +set SOURCEDIR=. +set BUILDDIR=_build +set SPHINXPROJ=brownpaperbag + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The Sphinx module was not found. Make sure you have Sphinx installed, + echo.then set the SPHINXBUILD environment variable to point to the full + echo.path of the 'sphinx-build' executable. Alternatively you may add the + echo.Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% + +:end +popd diff --git a/docs/readme.rst b/docs/readme.rst new file mode 100644 index 0000000..72a3355 --- /dev/null +++ b/docs/readme.rst @@ -0,0 +1 @@ +.. include:: ../README.rst diff --git a/docs/usage.rst b/docs/usage.rst new file mode 100644 index 0000000..911a4f6 --- /dev/null +++ b/docs/usage.rst @@ -0,0 +1,7 @@ +===== +Usage +===== + +To use brownpaperbag in a project:: + + import brownpaperbag diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index cffeec6..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,2 +0,0 @@ -pytest -pytest-cov \ No newline at end of file diff --git a/requirements-lint.txt b/requirements-lint.txt deleted file mode 100644 index de0828a..0000000 --- a/requirements-lint.txt +++ /dev/null @@ -1,8 +0,0 @@ -flake8 -flake8-black -flake8-import-order -flake8-blind-except -flake8-builtins -flake8-logging-format -flake8-docstrings -flake8-requirements \ No newline at end of file diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000..4ea07ea --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,12 @@ +pip==18.1 +bumpversion==0.5.3 +wheel==0.32.1 +watchdog==0.9.0 +flake8==3.5.0 +tox==3.5.2 +coverage==4.5.1 +Sphinx==1.8.1 +twine==1.12.1 + +pytest==3.8.2 +pytest-runner==4.2 diff --git a/setup.cfg b/setup.cfg index 224a779..2d20258 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,26 @@ -[metadata] -description-file = README.md \ No newline at end of file +[bumpversion] +current_version = 0.0.5 +commit = True +tag = True + +[bumpversion:file:setup.py] +search = version='{current_version}' +replace = version='{new_version}' + +[bumpversion:file:brownpaperbag/__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 index e952118..589b9a3 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,53 @@ -"""BrownPaperBag.""" -from distutils.core import setup +#!/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( - name="brownpaperbag", - packages=["brownpaperbag"], - version="0.0.5", - description="But you try and tell the young people today that... ", - author="bpaulin", - author_email="brunopaulin@bpaulin.net", - url="https://github.com/bpaulin/brownpaperbag", - download_url="https://github.com/bpaulin/brownpaperbag/archive/0.0.5.tar.gz", - keywords=["testing", "openwebnet"], - classifiers=[], - scripts=["bin/brownpaperbag"], + author="Bruno Paulin", + author_email='brunopaulin@bpaulin.net', + classifiers=[ + 'Development Status :: 2 - Pre-Alpha', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Natural Language :: English', + '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="But you try and tell the young people today that...", + entry_points={ + 'console_scripts': [ + 'brownpaperbag=brownpaperbag.cli:main', + ], + }, + install_requires=requirements, + license="MIT license", + long_description=readme + '\n\n' + history, + include_package_data=True, + keywords='brownpaperbag', + name='brownpaperbag', + packages=find_packages(include=['brownpaperbag']), + setup_requires=setup_requirements, + test_suite='tests', + tests_require=test_requirements, + url='https://github.com/bpaulin/brownpaperbag', + version='0.0.5', + zip_safe=False, ) diff --git a/tests/test_brownpaperbag.py b/tests/test_brownpaperbag.py new file mode 100644 index 0000000..65249d5 --- /dev/null +++ b/tests/test_brownpaperbag.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +"""Tests for `brownpaperbag` package.""" + +import pytest + +from click.testing import CliRunner + +from brownpaperbag import brownpaperbag +from brownpaperbag 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 'brownpaperbag.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 diff --git a/tox.ini b/tox.ini index 9ce6ad1..ce7ad6f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,21 +1,27 @@ [tox] -envlist = py35, py36, py37, flake8 -skip_missing_interpreters=true -usedevelop=true +envlist = py34, py35, py36, flake8 -[flake8] -exclude = .venv, .tox, tests -max-line-length = 88 -extend-ignore = - E203, +[travis] +python = + 3.6: py36 + 3.5: py35 + 3.4: py34 + +[testenv:flake8] +basepython = python +deps = flake8 +commands = flake8 brownpaperbag [testenv] setenv = PYTHONPATH = {toxinidir} +deps = + -r{toxinidir}/requirements_dev.txt +; If you want to make tox run the tests with the same versions, create a +; requirements.txt with the pinned versions and uncomment the following line: +; -r{toxinidir}/requirements.txt commands = - pytest --cov=brownpaperbag --cov-report=term -deps = -r requirements-dev.txt + pip install -U pip + py.test --basetemp={envtmpdir} + -[testenv:flake8] -commands = flake8 -deps = -r requirements-lint.txt \ No newline at end of file