Skip to content

Commit

Permalink
Merge pull request #6 from mattiassluis/master
Browse files Browse the repository at this point in the history
FIX requirements. OPT add support python 3.6
  • Loading branch information
Mattias authored Aug 15, 2017
2 parents 6449d31 + df4883b commit 176cdf8
Show file tree
Hide file tree
Showing 9 changed files with 187 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM kpndigital/tox:latest
FROM kpndigital/tox:py27_py35

WORKDIR /app

Expand Down
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# This Makefile requires the following commands to be available:
# * virtualenv
# * python2.7
# * python3.6
# * docker
# * docker-compose

Expand Down Expand Up @@ -32,7 +31,7 @@ clean: pyclean docsclean
@rm -rf .tox

venv:
@virtualenv -p python2.7 venv
@python3.6 -m venv venv
@$(PIP) install -U "pip>=7.0" -q
@$(PIP) install -U "pip>=7.0" -q
@$(PIP) install -r $(DEPS)
Expand Down Expand Up @@ -66,4 +65,4 @@ setup.py: venv
publish: setup.py
@$(PYTHON) setup.py sdist upload

build: clean venv tox setup.py
build: clean venv tox setup.py
8 changes: 8 additions & 0 deletions docs/api/fqn_decorators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ fqn_decorators
:undoc-members:
:show-inheritance:

fqn_decorators.async module
---------------------------

.. automodule:: fqn_decorators.async
:members:
:undoc-members:
:show-inheritance:

fqn_decorators.decorators module
--------------------------------

Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.napoleon',
'sphinxcontrib.plantuml',
]

plantuml_jar_path = os.path.abspath('./_plantuml/plantuml.jar')
Expand Down
1 change: 0 additions & 1 deletion requirements/requirements-base.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
pkgversion
2 changes: 1 addition & 1 deletion requirements/requirements-testing.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
tox
isort
flake8
pkgversion

# PyTest for running the tests.
pytest
pytest-cov

# docs
sphinx
sphinxcontrib-plantuml
sphinx_rtd_theme

mock
175 changes: 170 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,179 @@
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Internet :: WWW/HTTP'],
'description': 'Easily create multi-purpose decorators that have access to the FQN of the original function.',
'description': 'Easily create multi-purpose decorators that have access to '
'the FQN of the original function.',
'include_package_data': True,
'install_requires': ['pkgversion'],
'long_description': 'FQN Decorators\n==============\n\n.. image:: https://secure.travis-ci.org/kpn-digital/py-fqn-decorators.svg?branch=master\n :target: http://travis-ci.org/kpn-digital/py-fqn-decorators?branch=master\n\n.. image:: https://img.shields.io/codecov/c/github/kpn-digital/py-fqn-decorators/master.svg\n :target: http://codecov.io/github/kpn-digital/py-fqn-decorators?branch=master\n\n.. image:: https://img.shields.io/pypi/v/fqn-decorators.svg\n :target: https://pypi.python.org/pypi/fqn-decorators\n\n.. image:: https://readthedocs.org/projects/fqn-decorators/badge/?version=latest\n :target: http://fqn-decorators.readthedocs.org/en/latest/?badge=latest\n\n\nInstallation\n------------\n.. start_installation\n\nAt the command line::\n\n $ pip install fqn-decorators\n\n\n.. end_installation\n\nUsage\n-----\n.. start_usage\n.. py:currentmodule:: fqn_decorators.decorators\n\nIntroduction\n------------\n\nBy extending the :class:`~Decorator` class you can create simple decorators.\nImplement the :meth:`~Decorator.before` and/or :meth:`~Decorator.after` methods to perform actions before or after execution of the decorated item.\nThe :meth:`~Decorator.before` method can access the arguments of the decorated item by changing the :attr:`~Decorator.args` and :attr:`~Decorator.kwargs` attributes.\nThe :meth:`~Decorator.after` method can access or change the result using the :attr:`~Decorator.result` attribute.\nThe :meth:`~Decorator.exception` method can be used for do something with an Exception that has been raised.\nIn all three methods the :attr:`~Decorator.fqn` and :attr:`~Decorator.func` attributes are available.\n\nSimple decorator\n----------------\n\nCreate a simple decorator::\n\n import fqn_decorators\n import time\n\n class time_it(fqn_decorators.Decorator):\n\n def before(self):\n self.start = time.time()\n\n def after(self):\n duration = time.time() - self.start\n print("{0} took {1} seconds".format(self.fqn, duration))\n\n\n @time_it\n def my_function():\n time.sleep(1)\n\n >>>my_function()\n __main__.my_function took 1.00293397903 seconds\n\n\nDecorator with arguments\n------------------------\n\nIt is also very easy to create a decorator with arguments.\n\n.. note::\n It is not possible to create decorators with *non-keyworded* arguments.\n To create a decorator that supports non-keyworded arguments see the :ref:`Advanced Usage <usage_advanced_non_keyword_decorators>` section.\n\nExample::\n\n import fqn_decorators\n import time\n\n class threshold(fqn_decorators.Decorator):\n\n def before(self):\n self.start = time.time()\n\n def after(self):\n duration = time.time() - self.start\n treshold = self.params.get(\'threshold\')\n if threshold and duration > threshold:\n raise Exception(\'Execution took longer than the threshold\')\n\n\n @threshold(threshold=2)\n def my_function():\n time.sleep(3)\n\n >>> my_function()\n Exception: Execution took longer than the threshold\n\n.. end_usage\n',
'install_requires': [],
'long_description': 'FQN Decorators\n'
'==============\n'
'\n'
'.. image:: '
'https://secure.travis-ci.org/kpn-digital/py-fqn-decorators.svg?branch=master\n'
' :target: '
'http://travis-ci.org/kpn-digital/py-fqn-decorators?branch=master\n'
'\n'
'.. image:: '
'https://img.shields.io/codecov/c/github/kpn-digital/py-fqn-decorators/master.svg\n'
' :target: '
'http://codecov.io/github/kpn-digital/py-fqn-decorators?branch=master\n'
'\n'
'.. image:: '
'https://img.shields.io/pypi/v/fqn-decorators.svg\n'
' :target: '
'https://pypi.python.org/pypi/fqn-decorators\n'
'\n'
'.. image:: '
'https://readthedocs.org/projects/fqn-decorators/badge/?version=latest\n'
' :target: '
'http://fqn-decorators.readthedocs.org/en/latest/?badge=latest\n'
'\n'
'\n'
'Installation\n'
'------------\n'
'.. start_installation\n'
'\n'
'At the command line::\n'
'\n'
' $ pip install fqn-decorators\n'
'\n'
'\n'
'.. end_installation\n'
'\n'
'Usage\n'
'-----\n'
'.. start_usage\n'
'.. py:currentmodule:: fqn_decorators.decorators\n'
'\n'
'Introduction\n'
'------------\n'
'\n'
'By extending the :class:`~Decorator` class you can '
'create simple decorators.\n'
'Implement the :meth:`~Decorator.before` and/or '
':meth:`~Decorator.after` methods to perform actions '
'before or after execution of the decorated item.\n'
'The :meth:`~Decorator.before` method can access the '
'arguments of the decorated item by changing the '
':attr:`~Decorator.args` and :attr:`~Decorator.kwargs` '
'attributes.\n'
'The :meth:`~Decorator.after` method can access or change '
'the result using the :attr:`~Decorator.result` '
'attribute.\n'
'The :meth:`~Decorator.exception` method can be used for '
'do something with an Exception that has been raised.\n'
'In all three methods the :attr:`~Decorator.fqn` and '
':attr:`~Decorator.func` attributes are available.\n'
'\n'
'Simple decorator\n'
'----------------\n'
'\n'
'Create a simple decorator::\n'
'\n'
' import fqn_decorators\n'
' import time\n'
'\n'
' class time_it(fqn_decorators.Decorator):\n'
'\n'
' def before(self):\n'
' self.start = time.time()\n'
'\n'
' def after(self):\n'
' duration = time.time() - self.start\n'
' print("{0} took {1} '
'seconds".format(self.fqn, duration))\n'
'\n'
'\n'
' @time_it\n'
' def my_function():\n'
' time.sleep(1)\n'
'\n'
' >>>my_function()\n'
' __main__.my_function took 1.00293397903 seconds\n'
'\n'
'\n'
'Decorator with arguments\n'
'------------------------\n'
'\n'
'It is also very easy to create a decorator with '
'arguments.\n'
'\n'
'.. note::\n'
' It is not possible to create decorators with '
'*non-keyworded* arguments.\n'
' To create a decorator that supports non-keyworded '
'arguments see the :ref:`Advanced Usage '
'<usage_advanced_non_keyword_decorators>` section.\n'
'\n'
'Example::\n'
'\n'
' import fqn_decorators\n'
' import time\n'
'\n'
' class threshold(fqn_decorators.Decorator):\n'
'\n'
' def before(self):\n'
' self.start = time.time()\n'
'\n'
' def after(self):\n'
' duration = time.time() - self.start\n'
" treshold = self.params.get('threshold')\n"
' if threshold and duration > threshold:\n'
" raise Exception('Execution took longer "
"than the threshold')\n"
'\n'
'\n'
' @threshold(threshold=2)\n'
' def my_function():\n'
' time.sleep(3)\n'
'\n'
' >>> my_function()\n'
' Exception: Execution took longer than the threshold\n'
'\n'
'\n'
'Async Decorator\n'
'---------------\n'
'\n'
"There's also support for decorating coroutines (or any "
'awaitable), for Python >=3.5 only.\n'
'\n'
'The implementation is the same as with the sync version, '
'just inherit from\n'
':class:`~fqn_decorators.async.AsyncDecorator` instead.\n'
'\n'
'Example::\n'
'\n'
' import asyncio\n'
' import time\n'
' from fqn_decorators.async import AsyncDecorator\n'
'\n'
' class time_it_async(AsyncDecorator):\n'
'\n'
' def before(self):\n'
' self.start = time.time()\n'
'\n'
' def after(self):\n'
' duration = time.time() - self.start\n'
' print("{0} took {1} '
'seconds".format(self.fqn, duration))\n'
'\n'
' @time_it_async\n'
' async def coro():\n'
' await asyncio.sleep(1)\n'
'\n'
' >>> loop = asyncio.get_event_loop()\n'
' >>> loop.run_until_complete(coro())\n'
' __main__.coro took 1.001493215560913 seconds\n'
'\n'
'\n'
'.. end_usage\n',
'name': 'fqn-decorators',
'packages': ['fqn_decorators'],
'tests_require': ['tox'],
'url': 'ssh://git@github.com:kpn-digital/py-fqn-decorators.git',
'version': '1.0.0',
'url': 'https://github.com/kpn-digital/py-fqn-decorators',
'version': '1.2.0',
'zip_safe': False})
3 changes: 3 additions & 0 deletions setup_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Internet :: WWW/HTTP',
]
)
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
addopts=--tb=short

[tox]
envlist = py27,py35,isort-check,isort-fix,lint,docs
envlist = isort-check,isort-fix,lint,py27,py35,py36,docs
skipsdist = true

[testenv]
Expand Down

0 comments on commit 176cdf8

Please sign in to comment.