Skip to content

Commit 176cdf8

Browse files
author
Mattias
authored
Merge pull request #6 from mattiassluis/master
FIX requirements. OPT add support python 3.6
2 parents 6449d31 + df4883b commit 176cdf8

File tree

9 files changed

+187
-14
lines changed

9 files changed

+187
-14
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM kpndigital/tox:latest
1+
FROM kpndigital/tox:py27_py35
22

33
WORKDIR /app
44

Makefile

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# This Makefile requires the following commands to be available:
2-
# * virtualenv
3-
# * python2.7
2+
# * python3.6
43
# * docker
54
# * docker-compose
65

@@ -32,7 +31,7 @@ clean: pyclean docsclean
3231
@rm -rf .tox
3332

3433
venv:
35-
@virtualenv -p python2.7 venv
34+
@python3.6 -m venv venv
3635
@$(PIP) install -U "pip>=7.0" -q
3736
@$(PIP) install -U "pip>=7.0" -q
3837
@$(PIP) install -r $(DEPS)
@@ -66,4 +65,4 @@ setup.py: venv
6665
publish: setup.py
6766
@$(PYTHON) setup.py sdist upload
6867

69-
build: clean venv tox setup.py
68+
build: clean venv tox setup.py

docs/api/fqn_decorators.rst

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ fqn_decorators
66
:undoc-members:
77
:show-inheritance:
88

9+
fqn_decorators.async module
10+
---------------------------
11+
12+
.. automodule:: fqn_decorators.async
13+
:members:
14+
:undoc-members:
15+
:show-inheritance:
16+
917
fqn_decorators.decorators module
1018
--------------------------------
1119

docs/conf.py

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
'sphinx.ext.coverage',
3838
'sphinx.ext.mathjax',
3939
'sphinx.ext.napoleon',
40-
'sphinxcontrib.plantuml',
4140
]
4241

4342
plantuml_jar_path = os.path.abspath('./_plantuml/plantuml.jar')

requirements/requirements-base.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
pkgversion

requirements/requirements-testing.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
tox
22
isort
33
flake8
4+
pkgversion
45

56
# PyTest for running the tests.
67
pytest
78
pytest-cov
89

910
# docs
1011
sphinx
11-
sphinxcontrib-plantuml
1212
sphinx_rtd_theme
1313

1414
mock

setup.py

+170-5
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,179 @@
99
'Programming Language :: Python',
1010
'Programming Language :: Python :: 2',
1111
'Programming Language :: Python :: 2.7',
12+
'Programming Language :: Python :: 3',
13+
'Programming Language :: Python :: 3.5',
14+
'Programming Language :: Python :: 3.6',
1215
'Topic :: Internet :: WWW/HTTP'],
13-
'description': 'Easily create multi-purpose decorators that have access to the FQN of the original function.',
16+
'description': 'Easily create multi-purpose decorators that have access to '
17+
'the FQN of the original function.',
1418
'include_package_data': True,
15-
'install_requires': ['pkgversion'],
16-
'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',
19+
'install_requires': [],
20+
'long_description': 'FQN Decorators\n'
21+
'==============\n'
22+
'\n'
23+
'.. image:: '
24+
'https://secure.travis-ci.org/kpn-digital/py-fqn-decorators.svg?branch=master\n'
25+
' :target: '
26+
'http://travis-ci.org/kpn-digital/py-fqn-decorators?branch=master\n'
27+
'\n'
28+
'.. image:: '
29+
'https://img.shields.io/codecov/c/github/kpn-digital/py-fqn-decorators/master.svg\n'
30+
' :target: '
31+
'http://codecov.io/github/kpn-digital/py-fqn-decorators?branch=master\n'
32+
'\n'
33+
'.. image:: '
34+
'https://img.shields.io/pypi/v/fqn-decorators.svg\n'
35+
' :target: '
36+
'https://pypi.python.org/pypi/fqn-decorators\n'
37+
'\n'
38+
'.. image:: '
39+
'https://readthedocs.org/projects/fqn-decorators/badge/?version=latest\n'
40+
' :target: '
41+
'http://fqn-decorators.readthedocs.org/en/latest/?badge=latest\n'
42+
'\n'
43+
'\n'
44+
'Installation\n'
45+
'------------\n'
46+
'.. start_installation\n'
47+
'\n'
48+
'At the command line::\n'
49+
'\n'
50+
' $ pip install fqn-decorators\n'
51+
'\n'
52+
'\n'
53+
'.. end_installation\n'
54+
'\n'
55+
'Usage\n'
56+
'-----\n'
57+
'.. start_usage\n'
58+
'.. py:currentmodule:: fqn_decorators.decorators\n'
59+
'\n'
60+
'Introduction\n'
61+
'------------\n'
62+
'\n'
63+
'By extending the :class:`~Decorator` class you can '
64+
'create simple decorators.\n'
65+
'Implement the :meth:`~Decorator.before` and/or '
66+
':meth:`~Decorator.after` methods to perform actions '
67+
'before or after execution of the decorated item.\n'
68+
'The :meth:`~Decorator.before` method can access the '
69+
'arguments of the decorated item by changing the '
70+
':attr:`~Decorator.args` and :attr:`~Decorator.kwargs` '
71+
'attributes.\n'
72+
'The :meth:`~Decorator.after` method can access or change '
73+
'the result using the :attr:`~Decorator.result` '
74+
'attribute.\n'
75+
'The :meth:`~Decorator.exception` method can be used for '
76+
'do something with an Exception that has been raised.\n'
77+
'In all three methods the :attr:`~Decorator.fqn` and '
78+
':attr:`~Decorator.func` attributes are available.\n'
79+
'\n'
80+
'Simple decorator\n'
81+
'----------------\n'
82+
'\n'
83+
'Create a simple decorator::\n'
84+
'\n'
85+
' import fqn_decorators\n'
86+
' import time\n'
87+
'\n'
88+
' class time_it(fqn_decorators.Decorator):\n'
89+
'\n'
90+
' def before(self):\n'
91+
' self.start = time.time()\n'
92+
'\n'
93+
' def after(self):\n'
94+
' duration = time.time() - self.start\n'
95+
' print("{0} took {1} '
96+
'seconds".format(self.fqn, duration))\n'
97+
'\n'
98+
'\n'
99+
' @time_it\n'
100+
' def my_function():\n'
101+
' time.sleep(1)\n'
102+
'\n'
103+
' >>>my_function()\n'
104+
' __main__.my_function took 1.00293397903 seconds\n'
105+
'\n'
106+
'\n'
107+
'Decorator with arguments\n'
108+
'------------------------\n'
109+
'\n'
110+
'It is also very easy to create a decorator with '
111+
'arguments.\n'
112+
'\n'
113+
'.. note::\n'
114+
' It is not possible to create decorators with '
115+
'*non-keyworded* arguments.\n'
116+
' To create a decorator that supports non-keyworded '
117+
'arguments see the :ref:`Advanced Usage '
118+
'<usage_advanced_non_keyword_decorators>` section.\n'
119+
'\n'
120+
'Example::\n'
121+
'\n'
122+
' import fqn_decorators\n'
123+
' import time\n'
124+
'\n'
125+
' class threshold(fqn_decorators.Decorator):\n'
126+
'\n'
127+
' def before(self):\n'
128+
' self.start = time.time()\n'
129+
'\n'
130+
' def after(self):\n'
131+
' duration = time.time() - self.start\n'
132+
" treshold = self.params.get('threshold')\n"
133+
' if threshold and duration > threshold:\n'
134+
" raise Exception('Execution took longer "
135+
"than the threshold')\n"
136+
'\n'
137+
'\n'
138+
' @threshold(threshold=2)\n'
139+
' def my_function():\n'
140+
' time.sleep(3)\n'
141+
'\n'
142+
' >>> my_function()\n'
143+
' Exception: Execution took longer than the threshold\n'
144+
'\n'
145+
'\n'
146+
'Async Decorator\n'
147+
'---------------\n'
148+
'\n'
149+
"There's also support for decorating coroutines (or any "
150+
'awaitable), for Python >=3.5 only.\n'
151+
'\n'
152+
'The implementation is the same as with the sync version, '
153+
'just inherit from\n'
154+
':class:`~fqn_decorators.async.AsyncDecorator` instead.\n'
155+
'\n'
156+
'Example::\n'
157+
'\n'
158+
' import asyncio\n'
159+
' import time\n'
160+
' from fqn_decorators.async import AsyncDecorator\n'
161+
'\n'
162+
' class time_it_async(AsyncDecorator):\n'
163+
'\n'
164+
' def before(self):\n'
165+
' self.start = time.time()\n'
166+
'\n'
167+
' def after(self):\n'
168+
' duration = time.time() - self.start\n'
169+
' print("{0} took {1} '
170+
'seconds".format(self.fqn, duration))\n'
171+
'\n'
172+
' @time_it_async\n'
173+
' async def coro():\n'
174+
' await asyncio.sleep(1)\n'
175+
'\n'
176+
' >>> loop = asyncio.get_event_loop()\n'
177+
' >>> loop.run_until_complete(coro())\n'
178+
' __main__.coro took 1.001493215560913 seconds\n'
179+
'\n'
180+
'\n'
181+
'.. end_usage\n',
17182
'name': 'fqn-decorators',
18183
'packages': ['fqn_decorators'],
19184
'tests_require': ['tox'],
20-
'url': 'ssh://git@github.com:kpn-digital/py-fqn-decorators.git',
21-
'version': '1.0.0',
185+
'url': 'https://github.com/kpn-digital/py-fqn-decorators',
186+
'version': '1.2.0',
22187
'zip_safe': False})

setup_gen.py

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
'Programming Language :: Python',
2525
'Programming Language :: Python :: 2',
2626
'Programming Language :: Python :: 2.7',
27+
'Programming Language :: Python :: 3',
28+
'Programming Language :: Python :: 3.5',
29+
'Programming Language :: Python :: 3.6',
2730
'Topic :: Internet :: WWW/HTTP',
2831
]
2932
)

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
addopts=--tb=short
33

44
[tox]
5-
envlist = py27,py35,isort-check,isort-fix,lint,docs
5+
envlist = isort-check,isort-fix,lint,py27,py35,py36,docs
66
skipsdist = true
77

88
[testenv]

0 commit comments

Comments
 (0)