[Python-modules-commits] [python-venusian] 02/12: New upstream version 1.1.0
Takaki Taniguchi
takaki at moszumanska.debian.org
Tue Jul 4 05:49:03 UTC 2017
This is an automated email from the git hooks/post-receive script.
takaki pushed a commit to branch master
in repository python-venusian.
commit c3ac6cde909cf51f1c3141bf9ba58cbe089bdafc
Author: TANIGUCHI Takaki <takaki at asis.media-as.org>
Date: Mon Jul 3 18:50:43 2017 +0900
New upstream version 1.1.0
---
.gitignore | 27 +-
.travis.yml | 38 ++
CHANGES.txt => CHANGES.rst | 43 ++
CONTRIBUTORS.txt | 4 +
PKG-INFO | 62 ++-
README.txt => README.rst | 7 +
docs/api.rst | 5 +-
docs/conf.py | 7 +-
docs/index.rst | 11 +-
rtd.txt | 2 +-
setup.cfg | 10 +-
setup.py | 69 +--
tox.ini | 80 +++-
venusian.egg-info/PKG-INFO | 62 ++-
venusian.egg-info/SOURCES.txt | 17 +-
venusian.egg-info/requires.txt | 7 +-
venusian/__init__.py | 295 ++++++++++--
venusian/advice.py | 7 +-
venusian/{compat/__init__.py => compat.py} | 9 +-
venusian/compat/pkgutil_26.py | 586 ------------------------
venusian/tests/fixtures/__init__.py | 6 +-
venusian/tests/fixtures/class_and_method.py | 9 +
venusian/tests/fixtures/import_and_scan/mock.py | 27 ++
venusian/tests/fixtures/lifting1.py | 33 ++
venusian/tests/fixtures/lifting2.py | 35 ++
venusian/tests/fixtures/lifting3.py | 38 ++
venusian/tests/fixtures/lifting4.py | 23 +
venusian/tests/fixtures/lifting5.py | 38 ++
venusian/tests/fixtures/subclassing.py | 15 +
venusian/tests/fixtures/zipped.zip | Bin 0 -> 898 bytes
venusian/tests/test_venusian.py | 465 ++++++++++++++++---
31 files changed, 1227 insertions(+), 810 deletions(-)
diff --git a/.gitignore b/.gitignore
index 0e417a6..ef03d97 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,20 +1,29 @@
+*$py.class
*.egg
*.egg-info
-*.pyc
-*$py.class
*.pt.py
+*.pyc
+*.pyo
+*.swp
*.txt.py
*~
+.*.swp
+.cache/
.coverage
.tox/
-nosetests.xml
-pyramid/coverage.xml
-tutorial.db
-env*/
-jyenv/
-pypyenv/
+__pycache__/
build/
+coverage*.xml
+coverage-py*
+coverage.xml
dist/
-venusian/coverage.xml
docs/_build/
docs/_themes/
+env*/
+jyenv/
+nosetests-py*
+nosetests.xml
+pypyenv/
+pytest*.xml
+venusian.egg-info/
+venusian/coverage.xml
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..173e748
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,38 @@
+# Wire up travis
+language: python
+sudo: false
+
+matrix:
+ include:
+ - python: 2.7
+ env: TOXENV=py27
+ - python: 3.4
+ env: TOXENV=py34
+ - python: 3.5
+ env: TOXENV=py35
+ - python: pypy
+ env: TOXENV=pypy
+ - python: 3.5
+ env: TOXENV=py2-cover,py3-cover,coverage
+ - python: 3.5
+ env: TOXENV=docs
+ - python: 3.6
+ env: TOXENV=py36
+ - python: nightly
+ env: TOXENV=py37
+ allow_failures:
+ - env: TOXENV=py37
+
+install:
+ - travis_retry pip install tox
+
+script:
+ - travis_retry tox
+
+notifications:
+ email:
+ - pyramid-checkins at lists.repoze.org
+ irc:
+ channels:
+ - "chat.freenode.net#pyramid"
+
diff --git a/CHANGES.txt b/CHANGES.rst
similarity index 79%
rename from CHANGES.txt
rename to CHANGES.rst
index 9860e48..71ac65c 100644
--- a/CHANGES.txt
+++ b/CHANGES.rst
@@ -1,3 +1,46 @@
+1.1.0 (2017-04-24)
+------------------
+
+- Updated to using py.test instead of nosetest, and added support for Python
+ 3.4 -> 3.6
+
+- Make scanning more resilient of metaclasses that return proxies for any
+ attribute access.
+
+- Fix bug where using the same venusian decorator on both a class and its
+ methods would cause the method decorations to be ignored. See
+ https://github.com/Pylons/venusian/issues/40
+
+- Drop support for Python 2.6.
+
+- Drop support for Python 3.2: it is no longer supported by current
+ packaging / CI tools.
+
+- Support loaders that require the module name as argument to their
+ ``get_filename()`` method. This fixes problems with zipped packages
+ on Python 3.
+
+- Micro-optimization when ignores are used (see
+ https://github.com/Pylons/venusian/pull/20).
+
+- A tox run now combines coverage between Py2 and Py3.
+
+1.0 (2014-06-30)
+----------------
+
+- Fix an issue under PyPy > 2.0 where attached decorators may not be found.
+
+- Drop support of Python 2.4 / 2.5 / Jython.
+
+- Add ``lift`` and ``onlyliftedfrom`` class decorators to allow for inheritance
+ of venusian decorators attached to superclass methods. See the API
+ documentation for more information.
+
+- Fix bug where otherwise undecorated subclass of a superclass that had
+ venusian decorators on it would inherit its superclass' decorations.
+ Venusian decorators should have never been inherited implicitly. See
+ https://github.com/Pylons/venusian/issues/11#issuecomment-4977352
+
1.0a8 (2013-04-15)
------------------
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index cf17286..0f47947 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -104,3 +104,7 @@ Contributors
- Chris McDonough, 2011/02/16
- Chris Withers, 2011/03/14
- Joel Bohman, 2011/07/28
+- Olaf Conradi, 2013/09/16
+- Wichert Akkerman, 2015/02/23
+- Marc Abramowitz, 2015/02/24
+- Bert JW Regeer, 2017-04-24
diff --git a/PKG-INFO b/PKG-INFO
index 0d0a849..69dcc99 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: venusian
-Version: 1.0a8
+Version: 1.1.0
Summary: A library for deferring decorator actions
Home-page: http://pylonsproject.org
Author: Chris McDonough, Agendaless Consulting
@@ -9,6 +9,13 @@ License: BSD-derived (http://www.repoze.org/LICENSE.txt)
Description: venusian
========
+ .. image:: https://travis-ci.org/Pylons/venusian.png?branch=master
+ :target: https://travis-ci.org/Pylons/venusian
+
+ .. image:: https://readthedocs.org/projects/venusian/badge/?version=latest
+ :target: http://docs.pylonsproject.org/projects/venusian/en/latest/
+ :alt: Documentation Status
+
Venusian is a library which allows framework authors to defer
decorator actions. Instead of taking actions when a function (or
class) decorator is executed at import time, you can defer the action
@@ -18,6 +25,49 @@ Description: venusian
http://docs.pylonsproject.org/projects/venusian/en/latest/
+ 1.1.0 (2017-04-24)
+ ------------------
+
+ - Updated to using py.test instead of nosetest, and added support for Python
+ 3.4 -> 3.6
+
+ - Make scanning more resilient of metaclasses that return proxies for any
+ attribute access.
+
+ - Fix bug where using the same venusian decorator on both a class and its
+ methods would cause the method decorations to be ignored. See
+ https://github.com/Pylons/venusian/issues/40
+
+ - Drop support for Python 2.6.
+
+ - Drop support for Python 3.2: it is no longer supported by current
+ packaging / CI tools.
+
+ - Support loaders that require the module name as argument to their
+ ``get_filename()`` method. This fixes problems with zipped packages
+ on Python 3.
+
+ - Micro-optimization when ignores are used (see
+ https://github.com/Pylons/venusian/pull/20).
+
+ - A tox run now combines coverage between Py2 and Py3.
+
+ 1.0 (2014-06-30)
+ ----------------
+
+ - Fix an issue under PyPy > 2.0 where attached decorators may not be found.
+
+ - Drop support of Python 2.4 / 2.5 / Jython.
+
+ - Add ``lift`` and ``onlyliftedfrom`` class decorators to allow for inheritance
+ of venusian decorators attached to superclass methods. See the API
+ documentation for more information.
+
+ - Fix bug where otherwise undecorated subclass of a superclass that had
+ venusian decorators on it would inherit its superclass' decorations.
+ Venusian decorators should have never been inherited implicitly. See
+ https://github.com/Pylons/venusian/issues/11#issuecomment-4977352
+
1.0a8 (2013-04-15)
------------------
@@ -185,16 +235,14 @@ Description: venusian
Keywords: web wsgi zope
Platform: UNKNOWN
-Classifier: Development Status :: 3 - Alpha
+Classifier: Development Status :: 6 - Mature
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 2.4
-Classifier: Programming Language :: Python :: 2.5
-Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
-Classifier: Programming Language :: Python :: Implementation :: Jython
diff --git a/README.txt b/README.rst
similarity index 56%
rename from README.txt
rename to README.rst
index 8ab73b6..f8e6cd3 100644
--- a/README.txt
+++ b/README.rst
@@ -1,6 +1,13 @@
venusian
========
+.. image:: https://travis-ci.org/Pylons/venusian.png?branch=master
+ :target: https://travis-ci.org/Pylons/venusian
+
+.. image:: https://readthedocs.org/projects/venusian/badge/?version=latest
+ :target: http://docs.pylonsproject.org/projects/venusian/en/latest/
+ :alt: Documentation Status
+
Venusian is a library which allows framework authors to defer
decorator actions. Instead of taking actions when a function (or
class) decorator is executed at import time, you can defer the action
diff --git a/docs/api.rst b/docs/api.rst
index 284d2b3..13a8fa5 100644
--- a/docs/api.rst
+++ b/docs/api.rst
@@ -9,5 +9,8 @@ API Documentation for Venusian
.. autoclass:: AttachInfo
- .. autofunction:: attach(wrapped, callback, category=None)
+ .. autofunction:: attach(wrapped, callback, category=None, name=None)
+ .. autoclass:: lift
+
+ .. autoclass:: onlyliftedfrom
diff --git a/docs/conf.py b/docs/conf.py
index 6ca271b..521442c 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -15,6 +15,7 @@
import sys
import os
import datetime
+import pkg_resources
# Add and use Pylons theme
if 'sphinx-build' in ' '.join(sys.argv): # protect against dumb importers
@@ -60,7 +61,9 @@ html_theme_options = dict(github_url='https://github.com/Pylons/venusian')
# 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']
+extensions = [
+ 'sphinx.ext.autodoc',
+]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['.templates']
@@ -80,7 +83,7 @@ copyright = '2012-%s Pylons Project <pylons-discuss at googlegroups.com>' % year
# other places throughout the built documents.
#
# The short X.Y version.
-version = '1.0a8'
+version = pkg_resources.get_distribution('venusian').version
# The full version, including alpha/beta/rc tags.
release = version
diff --git a/docs/index.rst b/docs/index.rst
index 4244a01..a23481b 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -1,3 +1,5 @@
+.. _venusian:
+
Venusian
========
@@ -7,8 +9,7 @@ class decorator is executed at import time, you can defer the action
until a separate "scan" phase.
This library is most useful for framework authors. It is compatible with
-CPython versions 2.4, 2.5, 2.6, 2.7, and 3.2. It also is known to work on
-PyPy 1.5 and Jython 2.5.2.
+CPython versions 2.7, and 3.3+. It is also known to work on PyPy 1.5.
.. note::
@@ -232,7 +233,7 @@ Here's what happens as a result of invoking the
module will be inspected to see if it has had a Venusian callback
attached to it.
-#. For every object that *does* have an Venusian callback attached to
+#. For every object that *does* have a Venusian callback attached to
it, the callback is called.
We could have also passed the ``scan`` method a Python *package*
@@ -315,7 +316,7 @@ we'll pass to our scanner's constructor:
def add(self, name, ob):
self.registered.append((name, ob))
- register = Register()
+ registry = Registry()
scanner = venusian.Scanner(registry=registry)
scanner.scan(theapp)
@@ -478,7 +479,7 @@ The sequence can contain any of these three types of objects:
it is not ignored. If the callable matches a package name, the package as
well as any of that package's submodules and subpackages (recursively) will
be ignored. If the callable matches a module name, that module and any of
- its contained global objects will be ignored. If the callable mactches a
+ its contained global objects will be ignored. If the callable matches a
global object name, only that object name will be ignored. For example, if
you want to skip all packages, modules, and global objects that have a full
dotted name that ends with the word "tests", you can use
diff --git a/rtd.txt b/rtd.txt
index f4eb4ef..142b6ca 100644
--- a/rtd.txt
+++ b/rtd.txt
@@ -1 +1 @@
-repoze.sphinx.autointerface
+-e .[docs]
diff --git a/setup.cfg b/setup.cfg
index d385ff3..fe2fff8 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,13 +1,9 @@
[easy_install]
zip_ok = false
-[nosetests]
-match = ^test
-where = venusian
-nocapture = 1
-cover-package = venusian
-cover-erase = 1
-exclude-dir = venusian/tests/fixtures
+[tools:pytest]
+ignore = venusian/tests/fixtures/
+testpaths = venusian/tests/
[aliases]
dev = develop easy_install venusian[testing]
diff --git a/setup.py b/setup.py
index 83d6709..69c93c9 100644
--- a/setup.py
+++ b/setup.py
@@ -20,34 +20,42 @@ from setuptools import find_packages
here = os.path.abspath(os.path.dirname(__file__))
try:
- README = open(os.path.join(here, 'README.txt')).read()
- CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()
+ with open(os.path.join(here, 'README.rst')) as f:
+ README = f.read()
+ with open(os.path.join(here, 'CHANGES.rst')) as f:
+ CHANGES = f.read()
except:
README = ''
CHANGES = ''
-tests_extras = ['nose', 'nose-exclude', 'coverage']
-docs_extras = ['Sphinx', 'repoze.sphinx.autointerface']
+testing_extras = [
+ 'pytest',
+ 'coverage',
+ 'pytest-cov',
+]
+
+docs_extras = [
+ 'Sphinx',
+ 'repoze.sphinx.autointerface'
+]
setup(name='venusian',
- version='1.0a8',
+ version='1.1.0',
description='A library for deferring decorator actions',
- long_description=README + '\n\n' + CHANGES,
+ long_description=README + '\n\n' + CHANGES,
classifiers=[
- "Development Status :: 3 - Alpha",
- "Intended Audience :: Developers",
- "Programming Language :: Python",
- "Programming Language :: Python :: 2.4",
- "Programming Language :: Python :: 2.5",
- "Programming Language :: Python :: 2.6",
- "Programming Language :: Python :: 2.7",
- "Programming Language :: Python :: 3",
- "Programming Language :: Python :: 3.2",
- "Programming Language :: Python :: 3.3",
- "Programming Language :: Python :: Implementation :: CPython",
- "Programming Language :: Python :: Implementation :: PyPy",
- "Programming Language :: Python :: Implementation :: Jython",
- ],
+ "Development Status :: 6 - Mature",
+ "Intended Audience :: Developers",
+ "Programming Language :: Python",
+ "Programming Language :: Python :: 2.7",
+ "Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3.3",
+ "Programming Language :: Python :: 3.4",
+ "Programming Language :: Python :: 3.5",
+ "Programming Language :: Python :: 3.6",
+ "Programming Language :: Python :: Implementation :: CPython",
+ "Programming Language :: Python :: Implementation :: PyPy",
+ ],
keywords='web wsgi zope',
author="Chris McDonough, Agendaless Consulting",
author_email="pylons-devel at googlegroups.com",
@@ -56,20 +64,13 @@ setup(name='venusian',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
- extras_require = {
- 'testing':tests_extras,
- 'docs':docs_extras,
- },
- tests_require = [],
- install_requires = [],
- # Normal "setup.py test" can't support running the venusian tests under
- # py 2.4 or 2.5; when it scans the 'classdecorators' fixture, it
- # barfs. We can't depend on nose in setup_requires here because folks use
- # this under "pip bundle" which does not support setup_requires.
- # So you just have to know to install nose and run "setup.py nosetests"
- # rather than setup.py test.
+ extras_require={
+ 'testing': testing_extras,
+ 'docs': docs_extras,
+ },
+ tests_require=[],
+ install_requires=[],
test_suite='venusian',
- entry_points = """\
+ entry_points="""\
"""
)
-
diff --git a/tox.ini b/tox.ini
index 085e55b..100fe0f 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,31 +1,61 @@
[tox]
-envlist =
- py25,py26,py27,py32,jython,pypy,cover
+envlist =
+ py27,py33,py34,py35,py36,py37,pypy,
+ docs,
+ {py2,py3}-cover,coverage,
+skip_missing_interpreters = True
[testenv]
-commands =
- python setup.py nosetests
-deps =
- nose
- nose-exclude
+# Most of these are defaults but if you specify any you can't fall back
+# to defaults for others.
+basepython =
+ py27: python2.7
+ py33: python3.3
+ py34: python3.4
+ py35: python3.5
+ py36: python3.6
+ py37: python3.7
+ pypy: pypy
+ py2: python2.7
+ py3: python3.5
-[testenv:jython]
-commands =
- jython setup.py nosetests
+commands =
+ pip install -q venusian[testing]
+ py.test --junitxml=pytest-{envname}.xml {posargs:}
-[testenv:cover]
-basepython =
- python2.6
-commands =
- python setup.py nosetests --with-xunit --with-xcoverage
-deps =
- nose
- coverage==3.4
- nosexcover
- nose-exclude
-
-# we separate coverage into its own testenv because a) "last run wins" wrt
-# cobertura jenkins reporting and b) pypy and jython can't handle any
-# combination of versions of coverage and nosexcover that i can find.
-# coverage <3.4 is required by nosexcover 1.0.4.
+[testenv:docs]
+basepython = python3.5
+whitelist_externals = make
+commands =
+ pip install venusian[docs]
+ make -C docs html epub BUILDDIR={envdir} "SPHINXOPTS=-W -E"
+
+[py-cover]
+commands =
+ pip install venusian[testing]
+ py.test --cov-report term-missing --cov=venusian
+
+[testenv:py2-cover]
+commands =
+ {[py-cover]commands}
+setenv =
+ COVERAGE_FILE=.coverage.py2
+
+[testenv:py3-cover]
+commands =
+ {[py-cover]commands}
+setenv =
+ COVERAGE_FILE=.coverage.py3
+
+[testenv:coverage]
+basepython = python3.5
+commands =
+ coverage erase
+ coverage combine
+ coverage xml
+ coverage report --show-missing --fail-under=100
+deps =
+ coverage
+setenv =
+ COVERAGE_FILE=.coverage
diff --git a/venusian.egg-info/PKG-INFO b/venusian.egg-info/PKG-INFO
index 0d0a849..69dcc99 100644
--- a/venusian.egg-info/PKG-INFO
+++ b/venusian.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: venusian
-Version: 1.0a8
+Version: 1.1.0
Summary: A library for deferring decorator actions
Home-page: http://pylonsproject.org
Author: Chris McDonough, Agendaless Consulting
@@ -9,6 +9,13 @@ License: BSD-derived (http://www.repoze.org/LICENSE.txt)
Description: venusian
========
+ .. image:: https://travis-ci.org/Pylons/venusian.png?branch=master
+ :target: https://travis-ci.org/Pylons/venusian
+
+ .. image:: https://readthedocs.org/projects/venusian/badge/?version=latest
+ :target: http://docs.pylonsproject.org/projects/venusian/en/latest/
+ :alt: Documentation Status
+
Venusian is a library which allows framework authors to defer
decorator actions. Instead of taking actions when a function (or
class) decorator is executed at import time, you can defer the action
@@ -18,6 +25,49 @@ Description: venusian
http://docs.pylonsproject.org/projects/venusian/en/latest/
+ 1.1.0 (2017-04-24)
+ ------------------
+
+ - Updated to using py.test instead of nosetest, and added support for Python
+ 3.4 -> 3.6
+
+ - Make scanning more resilient of metaclasses that return proxies for any
+ attribute access.
+
+ - Fix bug where using the same venusian decorator on both a class and its
+ methods would cause the method decorations to be ignored. See
+ https://github.com/Pylons/venusian/issues/40
+
+ - Drop support for Python 2.6.
+
+ - Drop support for Python 3.2: it is no longer supported by current
+ packaging / CI tools.
+
+ - Support loaders that require the module name as argument to their
+ ``get_filename()`` method. This fixes problems with zipped packages
+ on Python 3.
+
+ - Micro-optimization when ignores are used (see
+ https://github.com/Pylons/venusian/pull/20).
+
+ - A tox run now combines coverage between Py2 and Py3.
+
+ 1.0 (2014-06-30)
+ ----------------
+
+ - Fix an issue under PyPy > 2.0 where attached decorators may not be found.
+
+ - Drop support of Python 2.4 / 2.5 / Jython.
+
+ - Add ``lift`` and ``onlyliftedfrom`` class decorators to allow for inheritance
+ of venusian decorators attached to superclass methods. See the API
+ documentation for more information.
+
+ - Fix bug where otherwise undecorated subclass of a superclass that had
+ venusian decorators on it would inherit its superclass' decorations.
+ Venusian decorators should have never been inherited implicitly. See
+ https://github.com/Pylons/venusian/issues/11#issuecomment-4977352
+
1.0a8 (2013-04-15)
------------------
@@ -185,16 +235,14 @@ Description: venusian
Keywords: web wsgi zope
Platform: UNKNOWN
-Classifier: Development Status :: 3 - Alpha
+Classifier: Development Status :: 6 - Mature
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 2.4
-Classifier: Programming Language :: Python :: 2.5
-Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
-Classifier: Programming Language :: Python :: Implementation :: Jython
diff --git a/venusian.egg-info/SOURCES.txt b/venusian.egg-info/SOURCES.txt
index d7abce1..2eb3e72 100644
--- a/venusian.egg-info/SOURCES.txt
+++ b/venusian.egg-info/SOURCES.txt
@@ -1,9 +1,10 @@
.gitignore
-CHANGES.txt
+.travis.yml
+CHANGES.rst
CONTRIBUTORS.txt
COPYRIGHT.txt
LICENSE.txt
-README.txt
+README.rst
rtd.txt
setup.cfg
setup.py
@@ -17,6 +18,7 @@ docs/.static/logo_hi.gif
docs/.static/repoze.css
venusian/__init__.py
venusian/advice.py
+venusian/compat.py
venusian.egg-info/PKG-INFO
venusian.egg-info/SOURCES.txt
venusian.egg-info/dependency_links.txt
@@ -24,20 +26,27 @@ venusian.egg-info/entry_points.txt
venusian.egg-info/not-zip-safe
venusian.egg-info/requires.txt
venusian.egg-info/top_level.txt
-venusian/compat/__init__.py
-venusian/compat/pkgutil_26.py
venusian/tests/__init__.py
venusian/tests/test_advice.py
venusian/tests/test_venusian.py
venusian/tests/fixtures/__init__.py
venusian/tests/fixtures/category.py
+venusian/tests/fixtures/class_and_method.py
venusian/tests/fixtures/classdecorator.py
venusian/tests/fixtures/inheritance.py
+venusian/tests/fixtures/lifting1.py
+venusian/tests/fixtures/lifting2.py
+venusian/tests/fixtures/lifting3.py
+venusian/tests/fixtures/lifting4.py
+venusian/tests/fixtures/lifting5.py
+venusian/tests/fixtures/subclassing.py
+venusian/tests/fixtures/zipped.zip
venusian/tests/fixtures/attrerror/__init__.py
venusian/tests/fixtures/attrerror/will_cause_import_error.py
venusian/tests/fixtures/attrerror_package/__init__.py
venusian/tests/fixtures/attrerror_package/will_cause_import_error/__init__.py
venusian/tests/fixtures/import_and_scan/__init__.py
+venusian/tests/fixtures/import_and_scan/mock.py
venusian/tests/fixtures/import_and_scan/one.py
venusian/tests/fixtures/import_and_scan/two.py
venusian/tests/fixtures/importerror/__init__.py
diff --git a/venusian.egg-info/requires.txt b/venusian.egg-info/requires.txt
index 8a3cbe0..c16f67a 100644
--- a/venusian.egg-info/requires.txt
+++ b/venusian.egg-info/requires.txt
@@ -1,10 +1,9 @@
-
[docs]
Sphinx
repoze.sphinx.autointerface
[testing]
-nose
-nose-exclude
-coverage
\ No newline at end of file
+pytest
+coverage
+pytest-cov
diff --git a/venusian/__init__.py b/venusian/__init__.py
index fd4f408..c068180 100644
--- a/venusian/__init__.py
+++ b/venusian/__init__.py
@@ -1,12 +1,17 @@
import imp
-from inspect import getmembers
+from inspect import getmembers, getmro, isclass
+from pkgutil import iter_modules
import sys
-from venusian.compat import iter_modules
-from venusian.compat import is_nonstr_iter
+from venusian.compat import (
+ is_nonstr_iter,
+ INT_TYPES,
+ )
+
from venusian.advice import getFrameInfo
ATTACH_ATTR = '__venusian_callbacks__'
+LIFTONLY_ATTR = '__venusian_liftonly_callbacks__'
class Scanner(object):
def __init__(self, **kw):
@@ -105,25 +110,32 @@ class Scanner(object):
if ignore is not None and not is_nonstr_iter(ignore):
ignore = [ignore]
+ elif ignore is None:
+ ignore = []
+
+ # non-leading-dotted name absolute object name
+ str_ignores = [ign for ign in ignore if isinstance(ign, str)]
+ # leading dotted name relative to scanned package
+ rel_ignores = [ign for ign in str_ignores if ign.startswith('.')]
+ # non-leading dotted names
+ abs_ignores = [ign for ign in str_ignores if not ign.startswith('.')]
+ # functions, e.g. re.compile('pattern').search
+ callable_ignores = [ign for ign in ignore if callable(ign)]
def _ignore(fullname):
- if ignore is not None:
- for ign in ignore:
- if isinstance(ign, str):
- if ign.startswith('.'):
- # leading dotted name relative to scanned package
- if fullname.startswith(pkg_name + ign):
- return True
- else:
- # non-leading-dotted name absolute object name
- if fullname.startswith(ign):
- return True
- else:
- # function
- if ign(fullname):
- return True
+ for ign in rel_ignores:
+ if fullname.startswith(pkg_name + ign):
+ return True
+ for ign in abs_ignores:
+ # non-leading-dotted name absolute object name
+ if fullname.startswith(ign):
+ return True
+ for ign in callable_ignores:
+ if ign(fullname):
+ return True
return False
+
def invoke(mod_name, name, ob):
fullname = mod_name + '.' + name
@@ -150,21 +162,34 @@ class Scanner(object):
# catchall except: return here, which in any other case would
# be high treason.
attached_categories = getattr(ob, ATTACH_ATTR)
- if not attached_categories.attached_to(ob):
+ if not attached_categories.attached_to(mod_name, name, ob):
return
except:
return
if category_keys is None:
category_keys = list(attached_categories.keys())
- category_keys.sort()
+ try:
+ # When metaclasses return proxies for any attribute access
+ # the list may contain keys of different types which might
+ # not be sortable. In that case we can just return,
+ # because we're not dealing with a proper venusian
+ # callback.
+ category_keys.sort()
+ except TypeError: # pragma: no cover
+ return
for category in category_keys:
callbacks = attached_categories.get(category, [])
- for callback, callback_mod_name in callbacks:
- if callback_mod_name != mod_name:
- # avoid processing objects that were imported into this
- # module but were not actually defined there
- continue
- callback(self, name, ob)
+ try:
+ # Metaclasses might trick us by reaching this far and then
+ # fail with too little values to unpack.
+ for callback, cb_mod_name, liftid, scope in callbacks:
+ if cb_mod_name != mod_name:
+ # avoid processing objects that were imported into
+ # this module but were not actually defined there
+ continue
+ callback(self, name, ob)
+ except ValueError:
+ continue
for name, ob in getmembers(package):
# whether it's a module or a package, we need to scan its
@@ -186,7 +211,13 @@ class Scanner(object):
else: # pragma: no cover
# py3.3b2+ (importlib-using)
module_type = imp.PY_SOURCE
- fn = loader.get_filename()
+ get_filename = getattr(loader, 'get_filename', None)
+ if get_filename is None:
+ get_filename = loader._get_filename
+ try:
+ fn = get_filename(modname)
+ except TypeError:
+ fn = get_filename()
if fn.endswith(('.pyc', '.pyo', '$py.class')):
module_type = imp.PY_COMPILED
# only scrape members from non-orphaned source files
@@ -254,41 +285,68 @@ class AttachInfo(object):
class Categories(dict):
def __init__(self, attached_to):
super(dict, self).__init__()
- if attached_to is None:
- self.attached_id = None
+ if isinstance(attached_to, tuple):
+ self.attached_id = attached_to
else:
self.attached_id = id(attached_to)
+ self.lifted = False
- def attached_to(self, obj):
- if self.attached_id:
+ def attached_to(self, mod_name, name, obj):
+ if isinstance(self.attached_id, INT_TYPES):
return self.attached_id == id(obj)
- return True
-
-def attach(wrapped, callback, category=None, depth=1):
+ return self.attached_id == (mod_name, name)
+
+def attach(wrapped, callback, category=None, depth=1, name=None):
""" Attach a callback to the wrapped object. It will be found
later during a scan. This function returns an instance of the
- :class:`venusian.AttachInfo` class."""
+ :class:`venusian.AttachInfo` class.
+
+ ``category`` should be ``None`` or a string representing a decorator
+ category name.
+
+ ``name`` should be ``None`` or a string representing a subcategory within
+ the category. This will be used by the ``lift`` class decorator to
+ determine if decorations of a method should be inherited or overridden.
+ """
frame = sys._getframe(depth+1)
scope, module, f_locals, f_globals, codeinfo = getFrameInfo(frame)
module_name = getattr(module, '__name__', None)
+ wrapped_name = getattr(wrapped, '__name__', None)
+ class_name = codeinfo[2]
+
+ liftid = '%s %s' % (wrapped_name, name)
+
if scope == 'class':
# we're in the midst of a class statement
- categories = f_locals.setdefault(ATTACH_ATTR, Categories(None))
+ categories = f_locals.get(ATTACH_ATTR, None)
+ if categories is None or not categories.attached_to(
+ module_name, class_name, None
+ ):
+ categories = Categories((module_name, class_name))
+ f_locals[ATTACH_ATTR] = categories
callbacks = categories.setdefault(category, [])
- callbacks.append((callback, module_name))
else:
categories = getattr(wrapped, ATTACH_ATTR, None)
- if categories is None or not categories.attached_to(wrapped):
+ if categories is None or not categories.attached_to(
+ module_name, wrapped_name, wrapped
+ ):
# if there aren't any attached categories, or we've retrieved
# some by inheritance, we need to create new ones
categories = Categories(wrapped)
setattr(wrapped, ATTACH_ATTR, categories)
callbacks = categories.setdefault(category, [])
- callbacks.append((callback, module_name))
+
+ callbacks.append((callback, module_name, liftid, scope))
+
return AttachInfo(
- scope=scope, module=module, locals=f_locals, globals=f_globals,
- category=category, codeinfo=codeinfo)
+ scope=scope,
+ module=module,
+ locals=f_locals,
+ globals=f_globals,
+ category=category,
+ codeinfo=codeinfo,
+ )
... 1796 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-venusian.git
More information about the Python-modules-commits
mailing list