diff options
author | Ask Solem <ask@celeryproject.org> | 2016-04-11 13:05:11 -0700 |
---|---|---|
committer | Ask Solem <ask@celeryproject.org> | 2016-04-11 13:05:11 -0700 |
commit | 91f4118b7fb8c3e914a06013e56afd2cc98e31fb (patch) | |
tree | 8b38c76b8d5d2ad5fc3e805f1f9cbb9b022c3cb5 | |
parent | f9cadf426d8c15535ccd7bbc7487c05b013b6ae2 (diff) | |
download | py-amqp-91f4118b7fb8c3e914a06013e56afd2cc98e31fb.tar.gz |
Update README.rst
-rw-r--r-- | Makefile | 105 | ||||
-rw-r--r-- | README.rst | 13 | ||||
-rw-r--r-- | amqp/five.py | 23 | ||||
-rw-r--r-- | docs/includes/introduction.txt (renamed from docs/includes/intro.txt) | 0 | ||||
-rw-r--r-- | docs/index.rst | 2 | ||||
-rw-r--r-- | docs/templates/readme.txt | 15 |
6 files changed, 126 insertions, 32 deletions
@@ -1,69 +1,116 @@ +PROJ=amqp PYTHON=python -SPHINX_DIR="docs/" +GIT=git +TOX=tox +NOSETESTS=nosetests +ICONV=iconv +FLAKE8=flake8 +FLAKEPLUS=flakeplus + +SPHINX_DIR=docs/ SPHINX_BUILDDIR="${SPHINX_DIR}/_build" -README="README.rst" +README=README.rst README_SRC="docs/templates/readme.txt" SPHINX2RST="sphinx2rst" - SPHINX_HTMLDIR = "${SPHINX_BUILDDIR}/html" - -html: +DOCUMENTATION=Documentation +FLAKEPLUSTARGET=2.7 + +all: help + +help: + @echo "docs - Build documentation." + @echo "test-all - Run tests for all supported python versions." + @echo "distcheck ---------- - Check distribution for problems." + @echo " test - Run unittests using current python." + @echo " lint ------------ - Check codebase for problems." + @echo " apicheck - Check API reference coverage." + @echo " configcheck - Check configuration reference coverage." + @echo " readmecheck - Check README encoding." + @echo " flakes -------- - Check code for syntax and style errors." + @echo " flakecheck - Run flake8 on the source code." + @echo " flakepluscheck - Run flakeplus on the source code." + @echo "readme - Regenerate README.rst file." + @echo "clean-dist --------- - Clean all distribution build artifacts." + @echo " clean-git-force - Remove all uncomitted files." + @echo " clean ------------ - Non-destructive clean" + @echo " clean-pyc - Remove .pyc/__pycache__ files" + @echo " clean-docs - Remove documentation build artifacts." + @echo " clean-build - Remove setup artifacts." + +clean: clean-docs clean-pyc clean-build + +clean-dist: clean clean-git-force + +Documentation: (cd "$(SPHINX_DIR)"; $(MAKE) html) - mv "$(SPHINX_HTMLDIR)" Documentation + mv "$(SPHINX_HTMLDIR)" $(DOCUMENTATION) -docsclean: +docs: Documentation + +clean-docs: -rm -rf "$(SPHINX_BUILDDIR)" -htmlclean: - -rm -rf "$(SPHINX)" +lint: flakecheck apicheck configcheck readmecheck apicheck: (cd "$(SPHINX_DIR)"; $(MAKE) apicheck) +configcheck: + (cd "$(SPHINX_DIR)"; $(MAKE) configcheck) + flakecheck: - flake8 amqp + $(FLAKE8) "$(PROJ)" flakediag: -$(MAKE) flakecheck flakepluscheck: - flakeplus --2.7 amqp + $(FLAKEPLUS) --$(FLAKEPLUSTARGET) "$(PROJ)" flakeplusdiag: -$(MAKE) flakepluscheck flakes: flakediag flakeplusdiag -readmeclean: +clean-readme: -rm -f $(README) readmecheck: - iconv -f ascii -t ascii $(README) >/dev/null + $(ICONV) -f ascii -t ascii $(README) >/dev/null $(README): $(SPHINX2RST) $(README_SRC) --ascii > $@ -readme: readmeclean $(README) readmecheck - -test: - nosetests -xv amqp.tests - -cov: - nosetests -xv amqp.tests --with-coverage --cover-html --cover-branch +readme: clean-readme $(README) readmecheck -removepyc: +clean-pyc: -find . -type f -a \( -name "*.pyc" -o -name "*$$py.class" \) | xargs rm -find . -type d -name "__pycache__" | xargs rm -r -gitclean: - git clean -xdn +removepyc: clean-pyc -gitcleanforce: - git clean -xdf +clean-build: + rm -rf build/ dist/ .eggs/ *.egg-info/ .tox/ .coverage cover/ + +clean-git: + $(GIT) clean -xdn + +clean-git-force: + $(GIT) clean -xdf + +test-all: clean-pyc + $(TOX) + +test: + $(PYTHON) setup.py test + +cov: + $(NOSETESTS) -xv --with-coverage --cover-html --cover-branch -tox: removepyc - tox +build: + $(PYTHON) setup.py sdist bdist_wheel -distcheck: flakecheck apicheck readmecheck test gitclean +distcheck: lint test clean -dist: readme docsclean gitcleanforce removepyc +dist: readme clean-dist build @@ -2,6 +2,8 @@ Python AMQP 0.9.1 client library ===================================================================== +[build-status] [coverage] [bitdeli] + :Version: 2.0.0rc2 :Web: http://amqp.readthedocs.org/ :Download: http://pypi.python.org/pypi/amqp/ @@ -99,3 +101,14 @@ Further http://www.rabbitmq.com/devtools.html#python-dev +.. |build-status| image:: https://secure.travis-ci.org/celery/py-amqp.png?branch=master + :alt: Build status + :target: https://travis-ci.org/celery/py-amqp + +.. |coverage| image:: https://codecov.io/github/celery/py-amqp/coverage.svg?branch=master + :target: https://codecov.io/github/celery/py-amqp?branch=master + +.. |bitdeli| image:: https://d2weczhvl823v0.cloudfront.net/celery/py-amqp/trend.png + :alt: Bitdeli badge + :target: https://bitdeli.com/free + diff --git a/amqp/five.py b/amqp/five.py index f87b539..bf00b8b 100644 --- a/amqp/five.py +++ b/amqp/five.py @@ -41,7 +41,8 @@ __all__ = ['Counter', 'reload', 'UserList', 'UserDict', # ############# py3k ######################################################## -PY3 = sys.version_info[0] == 3 +PY3 = sys.version_info[0] >= 3 +PY2 = sys.version_info[0] < 3 try: reload = reload # noqa @@ -260,3 +261,23 @@ class WhateverIO(StringIO): def write(self, data): _SIO_write(self, data.decode() if isinstance(data, bytes) else data) + + + +def python_2_unicode_compatible(cls): + """A decorator that defines __unicode__ and __str__ methods under Python 2. + Under Python 3 it does nothing. + + To support Python 2 and 3 with a single code base, define a __str__ method + returning text and apply this decorator to the class. + + """ + if PY2: + if '__str__' not in cls.__dict__: + raise ValueError( + "@python_2_unicode_compatible cannot be applied " + "to {0} because it doesn't define __str__().".format( + cls.__name__)) + cls.__unicode__ = cls.__str__ + cls.__str__ = lambda self: self.__unicode__().encode('utf-8') + return cls diff --git a/docs/includes/intro.txt b/docs/includes/introduction.txt index 3c6609d..3c6609d 100644 --- a/docs/includes/intro.txt +++ b/docs/includes/introduction.txt diff --git a/docs/index.rst b/docs/index.rst index 46c8ddd..429ec40 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -2,7 +2,7 @@ amqp - Python AMQP low-level client library ============================================= -.. include:: includes/intro.txt +.. include:: includes/introduction.txt Contents ======== diff --git a/docs/templates/readme.txt b/docs/templates/readme.txt index 315cc1c..dc37b23 100644 --- a/docs/templates/readme.txt +++ b/docs/templates/readme.txt @@ -2,4 +2,17 @@ Python AMQP 0.9.1 client library ===================================================================== -.. include:: ../includes/intro.txt +[build-status] [coverage] [bitdeli] + +.. include:: ../includes/introduction.txt + +.. |build-status| image:: https://secure.travis-ci.org/celery/py-amqp.png?branch=master + :alt: Build status + :target: https://travis-ci.org/celery/py-amqp + +.. |coverage| image:: https://codecov.io/github/celery/py-amqp/coverage.svg?branch=master + :target: https://codecov.io/github/celery/py-amqp?branch=master + +.. |bitdeli| image:: https://d2weczhvl823v0.cloudfront.net/celery/py-amqp/trend.png + :alt: Bitdeli badge + :target: https://bitdeli.com/free |