zope.deprecation-4.4.0/0000755000076500000240000000000013401230431015504 5ustar jmaddenstaff00000000000000zope.deprecation-4.4.0/.coveragerc0000644000076500000240000000032013401230430017617 0ustar jmaddenstaff00000000000000[run] source = zope.deprecation omit = *old_location.py */new_package/* */old_package/* [report] exclude_lines = pragma: no cover if __name__ == '__main__': raise NotImplementedError zope.deprecation-4.4.0/.travis.yml0000644000076500000240000000102313401230430017610 0ustar jmaddenstaff00000000000000language: python python: - 2.7 - 3.4 - 3.5 - 3.6 - pypy - pypy3 jobs: include: - python: 3.7 dist: xenial script: - coverage run -m zope.testrunner --test-path=src - coverage run -a -m sphinx -b doctest -d docs/_build/doctrees docs docs/_build/doctest after_success: - coveralls notifications: email: false install: - pip install -U pip setuptools - pip install -U coveralls coverage - pip install -U -e ".[test,docs]" cache: pip before_cache: - rm -f $HOME/.cache/pip/log/debug.log zope.deprecation-4.4.0/CHANGES.rst0000644000076500000240000000477213401230430017317 0ustar jmaddenstaff00000000000000================================ ``zope.deprecation`` Changelog ================================ 4.4.0 (2018-12-03) ================== - Add support for Python 3.7. 4.3.0 (2017-08-07) ================== - Allow custom warning classes to be specified to override the default ``DeprecationWarning``. See https://github.com/zopefoundation/zope.deprecation/pull/7 - Add support for Python 3.6. - Drop support for Python 3.3. 4.2.0 (2016-11-07) ================== - Drop support for Python 2.6 and 3.2. - Add support for Python 3.5. 4.1.2 (2015-01-13) ================== - Do not require a ``self`` parameter for deprecated functions. See: https://github.com/zopefoundation/zope.deprecation/pull/1 4.1.1 (2014-03-19) ================== - Added explicit support for Python 3.4. 4.1.0 (2013-12-20) ================== - Added a ``Suppressor`` context manager, allowing scoped suppression of deprecation warnings. - Updated ``boostrap.py`` to version 2.2. 4.0.2 (2012-12-31) ================== - Fleshed out PyPI Trove classifiers. 4.0.1 (2012-11-21) ================== - Added support for Python 3.3. 4.0.0 (2012-05-16) ================== - Automated build of Sphinx HTML docs and running doctest snippets via tox. - Added Sphinx documentation: - API docs moved from package-data README into ``docs/api.rst``. - Snippets can be tested by running 'make doctest'. - Updated support for continuous integration using ``tox`` and ``jenkins``. - 100% unit test coverage. - Added ``setup.py dev`` alias (runs ``setup.py develop`` plus installs ``nose`` and ``coverage``). - Added ``setup.py docs`` alias (installs ``Sphinx`` and dependencies). - Removed spurious dependency on ``zope.testing``. - Dropped explicit support for Python 2.4 / 2.5 / 3.1. 3.5.1 (2012-03-15) ================== - Revert a move of `README.txt` to unbreak ``zope.app.apidoc``. 3.5.0 (2011-09-05) ================== - Replaced doctesting with unit testing. - Python 3 compatibility. 3.4.1 (2011-06-07) ================== - Removed import cycle for ``__show__`` by defining it in the ``zope.deprecation.deprecation`` module. - Added support to bootstrap on Jython. - Fix ``zope.deprecation.warn()`` to make the signature identical to ``warnings.warn()`` and to check for .pyc and .pyo files. 3.4.0 (2007-07-19) ================== - Release 3.4 final, corresponding to Zope 3.4. 3.3.0 (2007-02-18) ================== - Corresponds to the version of the ``zope.deprecation`` package shipped as part of the Zope 3.3.0 release. zope.deprecation-4.4.0/COPYRIGHT.txt0000644000076500000240000000004013401230430017606 0ustar jmaddenstaff00000000000000Zope Foundation and Contributorszope.deprecation-4.4.0/LICENSE.txt0000644000076500000240000000402613401230430017330 0ustar jmaddenstaff00000000000000Zope Public License (ZPL) Version 2.1 A copyright notice accompanies this license document that identifies the copyright holders. This license has been certified as open source. It has also been designated as GPL compatible by the Free Software Foundation (FSF). Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions in source code must retain the accompanying copyright notice, this list of conditions, and the following disclaimer. 2. Redistributions in binary form must reproduce the accompanying copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Names of the copyright holders must not be used to endorse or promote products derived from this software without prior written permission from the copyright holders. 4. The right to distribute this software or to use it for any purpose does not give you the right to use Servicemarks (sm) or Trademarks (tm) of the copyright holders. Use of them is covered by separate agreement with the copyright holders. 5. If any files are modified, you must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. Disclaimer THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. zope.deprecation-4.4.0/MANIFEST.in0000644000076500000240000000030613401230430017240 0ustar jmaddenstaff00000000000000include *.rst include *.txt include .coveragerc include tox.ini include .travis.yml include bootstrap.py include buildout.cfg recursive-include docs * recursive-include src * global-exclude *.pyc zope.deprecation-4.4.0/PKG-INFO0000644000076500000240000001336013401230431016604 0ustar jmaddenstaff00000000000000Metadata-Version: 2.1 Name: zope.deprecation Version: 4.4.0 Summary: Zope Deprecation Infrastructure Home-page: https://github.com/zopefoundation/zope.deprecation Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Description: ====================== ``zope.deprecation`` ====================== .. image:: https://img.shields.io/pypi/v/zope.deprecation.svg :target: https://pypi.python.org/pypi/zope.deprecation/ :alt: Latest release .. image:: https://img.shields.io/pypi/pyversions/zope.deprecation.svg :target: https://pypi.org/project/zope.deprecation/ :alt: Supported Python versions .. image:: https://travis-ci.org/zopefoundation/zope.deprecation.svg?branch=master :target: https://travis-ci.org/zopefoundation/zope.deprecation .. image:: https://coveralls.io/repos/github/zopefoundation/zope.deprecation/badge.svg?branch=master :target: https://coveralls.io/github/zopefoundation/zope.deprecation?branch=master .. image:: https://readthedocs.org/projects/zopedeprecation/badge/?version=latest :target: https://zopedeprecation.readthedocs.io/en/latest/ :alt: Documentation Status This package provides a simple function called ``deprecated(names, reason)`` to mark deprecated modules, classes, functions, methods and properties. Please see https://zopedeprecation.readthedocs.io for the documentation. ================================ ``zope.deprecation`` Changelog ================================ 4.4.0 (2018-12-03) ================== - Add support for Python 3.7. 4.3.0 (2017-08-07) ================== - Allow custom warning classes to be specified to override the default ``DeprecationWarning``. See https://github.com/zopefoundation/zope.deprecation/pull/7 - Add support for Python 3.6. - Drop support for Python 3.3. 4.2.0 (2016-11-07) ================== - Drop support for Python 2.6 and 3.2. - Add support for Python 3.5. 4.1.2 (2015-01-13) ================== - Do not require a ``self`` parameter for deprecated functions. See: https://github.com/zopefoundation/zope.deprecation/pull/1 4.1.1 (2014-03-19) ================== - Added explicit support for Python 3.4. 4.1.0 (2013-12-20) ================== - Added a ``Suppressor`` context manager, allowing scoped suppression of deprecation warnings. - Updated ``boostrap.py`` to version 2.2. 4.0.2 (2012-12-31) ================== - Fleshed out PyPI Trove classifiers. 4.0.1 (2012-11-21) ================== - Added support for Python 3.3. 4.0.0 (2012-05-16) ================== - Automated build of Sphinx HTML docs and running doctest snippets via tox. - Added Sphinx documentation: - API docs moved from package-data README into ``docs/api.rst``. - Snippets can be tested by running 'make doctest'. - Updated support for continuous integration using ``tox`` and ``jenkins``. - 100% unit test coverage. - Added ``setup.py dev`` alias (runs ``setup.py develop`` plus installs ``nose`` and ``coverage``). - Added ``setup.py docs`` alias (installs ``Sphinx`` and dependencies). - Removed spurious dependency on ``zope.testing``. - Dropped explicit support for Python 2.4 / 2.5 / 3.1. 3.5.1 (2012-03-15) ================== - Revert a move of `README.txt` to unbreak ``zope.app.apidoc``. 3.5.0 (2011-09-05) ================== - Replaced doctesting with unit testing. - Python 3 compatibility. 3.4.1 (2011-06-07) ================== - Removed import cycle for ``__show__`` by defining it in the ``zope.deprecation.deprecation`` module. - Added support to bootstrap on Jython. - Fix ``zope.deprecation.warn()`` to make the signature identical to ``warnings.warn()`` and to check for .pyc and .pyo files. 3.4.0 (2007-07-19) ================== - Release 3.4 final, corresponding to Zope 3.4. 3.3.0 (2007-02-18) ================== - Corresponds to the version of the ``zope.deprecation`` package shipped as part of the Zope 3.3.0 release. Keywords: deprecation,deprecated,warning Platform: UNKNOWN Classifier: Intended Audience :: Developers Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Framework :: Zope :: 3 Provides-Extra: docs Provides-Extra: test zope.deprecation-4.4.0/README.rst0000644000076500000240000000220213401230430017166 0ustar jmaddenstaff00000000000000====================== ``zope.deprecation`` ====================== .. image:: https://img.shields.io/pypi/v/zope.deprecation.svg :target: https://pypi.python.org/pypi/zope.deprecation/ :alt: Latest release .. image:: https://img.shields.io/pypi/pyversions/zope.deprecation.svg :target: https://pypi.org/project/zope.deprecation/ :alt: Supported Python versions .. image:: https://travis-ci.org/zopefoundation/zope.deprecation.svg?branch=master :target: https://travis-ci.org/zopefoundation/zope.deprecation .. image:: https://coveralls.io/repos/github/zopefoundation/zope.deprecation/badge.svg?branch=master :target: https://coveralls.io/github/zopefoundation/zope.deprecation?branch=master .. image:: https://readthedocs.org/projects/zopedeprecation/badge/?version=latest :target: https://zopedeprecation.readthedocs.io/en/latest/ :alt: Documentation Status This package provides a simple function called ``deprecated(names, reason)`` to mark deprecated modules, classes, functions, methods and properties. Please see https://zopedeprecation.readthedocs.io for the documentation. zope.deprecation-4.4.0/bootstrap.py0000644000076500000240000001644213401230430020101 0ustar jmaddenstaff00000000000000############################################################################## # # Copyright (c) 2006 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Bootstrap a buildout-based project Simply run this script in a directory containing a buildout.cfg. The script accepts buildout command-line options, so you can use the -c option to specify an alternate configuration file. """ import os import shutil import sys import tempfile from optparse import OptionParser __version__ = '2015-07-01' # See zc.buildout's changelog if this version is up to date. tmpeggs = tempfile.mkdtemp(prefix='bootstrap-') usage = '''\ [DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options] Bootstraps a buildout-based project. Simply run this script in a directory containing a buildout.cfg, using the Python that you want bin/buildout to use. Note that by using --find-links to point to local resources, you can keep this script from going over the network. ''' parser = OptionParser(usage=usage) parser.add_option("--version", action="store_true", default=False, help=("Return bootstrap.py version.")) parser.add_option("-t", "--accept-buildout-test-releases", dest='accept_buildout_test_releases', action="store_true", default=False, help=("Normally, if you do not specify a --version, the " "bootstrap script and buildout gets the newest " "*final* versions of zc.buildout and its recipes and " "extensions for you. If you use this flag, " "bootstrap and buildout will get the newest releases " "even if they are alphas or betas.")) parser.add_option("-c", "--config-file", help=("Specify the path to the buildout configuration " "file to be used.")) parser.add_option("-f", "--find-links", help=("Specify a URL to search for buildout releases")) parser.add_option("--allow-site-packages", action="store_true", default=False, help=("Let bootstrap.py use existing site packages")) parser.add_option("--buildout-version", help="Use a specific zc.buildout version") parser.add_option("--setuptools-version", help="Use a specific setuptools version") parser.add_option("--setuptools-to-dir", help=("Allow for re-use of existing directory of " "setuptools versions")) options, args = parser.parse_args() if options.version: print("bootstrap.py version %s" % __version__) sys.exit(0) ###################################################################### # load/install setuptools try: from urllib.request import urlopen except ImportError: from urllib2 import urlopen ez = {} if os.path.exists('ez_setup.py'): exec(open('ez_setup.py').read(), ez) else: exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez) if not options.allow_site_packages: # ez_setup imports site, which adds site packages # this will remove them from the path to ensure that incompatible versions # of setuptools are not in the path import site # inside a virtualenv, there is no 'getsitepackages'. # We can't remove these reliably if hasattr(site, 'getsitepackages'): for sitepackage_path in site.getsitepackages(): # Strip all site-packages directories from sys.path that # are not sys.prefix; this is because on Windows # sys.prefix is a site-package directory. if sitepackage_path != sys.prefix: sys.path[:] = [x for x in sys.path if sitepackage_path not in x] setup_args = dict(to_dir=tmpeggs, download_delay=0) if options.setuptools_version is not None: setup_args['version'] = options.setuptools_version if options.setuptools_to_dir is not None: setup_args['to_dir'] = options.setuptools_to_dir ez['use_setuptools'](**setup_args) import setuptools import pkg_resources # This does not (always?) update the default working set. We will # do it. for path in sys.path: if path not in pkg_resources.working_set.entries: pkg_resources.working_set.add_entry(path) ###################################################################### # Install buildout ws = pkg_resources.working_set setuptools_path = ws.find( pkg_resources.Requirement.parse('setuptools')).location # Fix sys.path here as easy_install.pth added before PYTHONPATH cmd = [sys.executable, '-c', 'import sys; sys.path[0:0] = [%r]; ' % setuptools_path + 'from setuptools.command.easy_install import main; main()', '-mZqNxd', tmpeggs] find_links = os.environ.get( 'bootstrap-testing-find-links', options.find_links or ('http://downloads.buildout.org/' if options.accept_buildout_test_releases else None) ) if find_links: cmd.extend(['-f', find_links]) requirement = 'zc.buildout' version = options.buildout_version if version is None and not options.accept_buildout_test_releases: # Figure out the most recent final version of zc.buildout. import setuptools.package_index _final_parts = '*final-', '*final' def _final_version(parsed_version): try: return not parsed_version.is_prerelease except AttributeError: # Older setuptools for part in parsed_version: if (part[:1] == '*') and (part not in _final_parts): return False return True index = setuptools.package_index.PackageIndex( search_path=[setuptools_path]) if find_links: index.add_find_links((find_links,)) req = pkg_resources.Requirement.parse(requirement) if index.obtain(req) is not None: best = [] bestv = None for dist in index[req.project_name]: distv = dist.parsed_version if _final_version(distv): if bestv is None or distv > bestv: best = [dist] bestv = distv elif distv == bestv: best.append(dist) if best: best.sort() version = best[-1].version if version: requirement = '=='.join((requirement, version)) cmd.append(requirement) import subprocess if subprocess.call(cmd) != 0: raise Exception( "Failed to execute command:\n%s" % repr(cmd)[1:-1]) ###################################################################### # Import and run buildout ws.add_entry(tmpeggs) ws.require(requirement) import zc.buildout.buildout if not [a for a in args if '=' not in a]: args.append('bootstrap') # if -c was provided, we push it back into args for buildout' main function if options.config_file is not None: args[0:0] = ['-c', options.config_file] zc.buildout.buildout.main(args) shutil.rmtree(tmpeggs) zope.deprecation-4.4.0/buildout.cfg0000644000076500000240000000014413401230430020012 0ustar jmaddenstaff00000000000000[buildout] parts = test develop = . [test] recipe = zc.recipe.testrunner eggs = zope.deprecation zope.deprecation-4.4.0/docs/0000755000076500000240000000000013401230431016434 5ustar jmaddenstaff00000000000000zope.deprecation-4.4.0/docs/Makefile0000644000076500000240000001274013401230430020077 0ustar jmaddenstaff00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/zopedeprecation.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/zopedeprecation.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/zopedeprecation" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/zopedeprecation" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." zope.deprecation-4.4.0/docs/_static/0000755000076500000240000000000013401230431020062 5ustar jmaddenstaff00000000000000zope.deprecation-4.4.0/docs/_static/.gitignore0000644000076500000240000000000013401230430022037 0ustar jmaddenstaff00000000000000zope.deprecation-4.4.0/docs/api.rst0000644000076500000240000003267213401230430017750 0ustar jmaddenstaff00000000000000============================= :mod:`zope.deprecation` API ============================= Deprecating objects inside a module =================================== Let's start with a demonstration of deprecating any name inside a module. To demonstrate the functionality, First, let's set up an example module containing fixtures we will use: .. doctest:: >>> import os >>> import tempfile >>> import zope.deprecation >>> tmp_d = tempfile.mkdtemp('deprecation') >>> zope.deprecation.__path__.append(tmp_d) >>> doctest_ex = '''\ ... from . import deprecated ... ... def demo1(): ... return 1 ... deprecated('demo1', 'demo1 is no more.') ... ... def demo2(): ... return 2 ... deprecated('demo2', 'demo2 is no more.') ... ... def demo3(): ... return 3 ... deprecated('demo3', 'demo3 is no more.') ... ... def demo4(): ... return 4 ... def deprecatedemo4(): ... """Demonstrate that deprecated() also works in a local scope.""" ... deprecated('demo4', 'demo4 is no more.') ... ''' >>> with open(os.path.join(tmp_d, 'doctest_ex.py'), 'w') as f: ... _ = f.write(doctest_ex) The first argument to the ``deprecated()`` function is a list of names that should be declared deprecated. If the first argument is a string, it is interpreted as one name. The second argument is the reason the particular name has been deprecated. It is good practice to also list the version in which the name will be removed completely. Let's now see how the deprecation warnings are displayed. .. doctest:: >>> import warnings >>> from zope.deprecation import doctest_ex >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... doctest_ex.demo1() 1 >>> print(log[0].category.__name__) DeprecationWarning >>> print(log[0].message) demo1: demo1 is no more. >>> import zope.deprecation.doctest_ex >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... zope.deprecation.doctest_ex.demo2() 2 >>> print(log[0].message) demo2: demo2 is no more. You can see that merely importing the affected module or one of its parents does not cause a deprecation warning. Only when we try to access the name in the module, we get a deprecation warning. On the other hand, if we import the name directly, the deprecation warning will be raised immediately. .. doctest:: >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... from zope.deprecation.doctest_ex import demo3 >>> print(log[0].message) demo3: demo3 is no more. Deprecation can also happen inside a function. When we first access ``demo4``, it can be accessed without problems, then we call a function that sets the deprecation message and we get the message upon the next access: .. doctest:: >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... doctest_ex.demo4() 4 >>> len(log) 0 >>> doctest_ex.deprecatedemo4() >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... doctest_ex.demo4() 4 >>> print(log[0].message) demo4: demo4 is no more. Deprecating methods and properties ================================== New let's see how properties and methods can be deprecated. We are going to use the same function as before, except that this time, we do not pass in names as first argument, but the method or attribute itself. The function then returns a wrapper that sends out a deprecation warning when the attribute or method is accessed. .. doctest:: >>> from zope.deprecation import deprecation >>> class MyComponent(object): ... foo = property(lambda self: 1) ... foo = deprecation.deprecated(foo, 'foo is no more.') ... ... bar = 2 ... ... def blah(self): ... return 3 ... blah = deprecation.deprecated(blah, 'blah() is no more.') ... ... def splat(self): ... return 4 ... ... @deprecation.deprecate("clap() is no more.") ... def clap(self): ... return 5 And here is the result: .. doctest:: >>> my = MyComponent() >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... my.foo 1 >>> print(log[0].message) foo is no more. >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... my.bar 2 >>> len(log) 0 >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... my.blah() 3 >>> print(log[0].message) blah() is no more. >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... my.splat() 4 >>> len(log) 0 >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... my.clap() 5 >>> print(log[0].message) clap() is no more. Deprecating modules =================== It is also possible to deprecate whole modules. This is useful when creating module aliases for backward compatibility. Let's imagine, the ``zope.deprecation`` module used to be called ``zope.wanda`` and we'd like to retain backward compatibility: .. doctest:: >>> import sys >>> sys.modules['zope.wanda'] = deprecation.deprecated( ... zope.deprecation, 'A module called Wanda is now zope.deprecation.') Now we can import ``wanda``, but when accessing things from it, we get our deprecation message as expected: .. doctest:: >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... from zope.wanda import deprecated >>> print(log[0].message) A module called Wanda is now zope.deprecation. Before we move on, we should clean up: .. doctest:: >>> del deprecated >>> del sys.modules['zope.wanda'] Moving modules ============== When a module is moved, you often want to support importing from the old location for a while, generating a deprecation warning when someone uses the old location. This can be done using the moved function. To see how this works, we'll use a helper function to create two fake modules in the zope.deprecation package. First will create a module in the "old" location that used the moved function to indicate the a module on the new location should be used: .. doctest:: >>> import os >>> created_modules = [] >>> def create_module(modules=(), **kw): #** highlightfail ... modules = dict(modules) ... modules.update(kw) ... for name, src in sorted(modules.items()): ... pname = name.split('.') ... if pname[-1] == '__init__': ... os.mkdir(os.path.join(tmp_d, *pname[:-1])) #* highlightfail ... name = '.'.join(pname[:-1]) ... with open(os.path.join(tmp_d, *pname) + '.py', 'w') as f: ... f.write(src) #* hf ... created_modules.append(name) ... import importlib ... if hasattr(importlib, 'invalidate_caches'): ... importlib.invalidate_caches() >>> create_module(old_location= ... ''' ... import zope.deprecation ... zope.deprecation.moved('zope.deprecation.new_location', 'version 2') ... ''') and we define the module in the new location: .. doctest:: >>> create_module(new_location= ... '''\ ... print("new module imported") ... x = 42 ... ''') Now, if we import the old location, we'll see the output of importing the old location: .. doctest:: >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... import zope.deprecation.old_location new module imported >>> print(log[0].message) ... # doctest: +NORMALIZE_WHITESPACE zope.deprecation.old_location has moved to zope.deprecation.new_location. Import of zope.deprecation.old_location will become unsupported in version 2 >>> zope.deprecation.old_location.x 42 Moving packages =============== When moving packages, you need to leave placeholders for each module. Let's look at an example: .. doctest:: >>> create_module({ ... 'new_package.__init__': '''\ ... print(__name__ + ' imported') ... x=0 ... ''', ... 'new_package.m1': '''\ ... print(__name__ + ' imported') ... x=1 ... ''', ... 'new_package.m2': '''\ ... print(__name__ + ' imported') ... def x(): ... pass ... ''', ... 'new_package.m3': '''\ ... print(__name__ + ' imported') ... x=3 ... ''', ... 'old_package.__init__': '''\ ... import zope.deprecation ... zope.deprecation.moved('zope.deprecation.new_package', 'version 2') ... ''', ... 'old_package.m1': '''\ ... import zope.deprecation ... zope.deprecation.moved('zope.deprecation.new_package.m1', 'version 2') ... ''', ... 'old_package.m2': '''\ ... import zope.deprecation ... zope.deprecation.moved('zope.deprecation.new_package.m2', 'version 2') ... ''', ... }) Now, if we import the old modules, we'll get warnings: .. doctest:: >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... import zope.deprecation.old_package zope.deprecation.new_package imported >>> print(log[0].message) ... # doctest: +NORMALIZE_WHITESPACE zope.deprecation.old_package has moved to zope.deprecation.new_package. Import of zope.deprecation.old_package will become unsupported in version 2 >>> zope.deprecation.old_package.x 0 >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... import zope.deprecation.old_package.m1 zope.deprecation.new_package.m1 imported >>> print(log[0].message) ... # doctest: +NORMALIZE_WHITESPACE zope.deprecation.old_package.m1 has moved to zope.deprecation.new_package.m1. Import of zope.deprecation.old_package.m1 will become unsupported in version 2 >>> zope.deprecation.old_package.m1.x 1 >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... import zope.deprecation.old_package.m2 zope.deprecation.new_package.m2 imported >>> print(log[0].message) ... # doctest: +NORMALIZE_WHITESPACE zope.deprecation.old_package.m2 has moved to zope.deprecation.new_package.m2. Import of zope.deprecation.old_package.m2 will become unsupported in version 2 >>> zope.deprecation.old_package.m2.x is zope.deprecation.new_package.m2.x True >>> (zope.deprecation.old_package.m2.x.__globals__ ... is zope.deprecation.new_package.m2.__dict__) True >>> zope.deprecation.old_package.m2.x.__module__ 'zope.deprecation.new_package.m2' We'll get an error if we try to import m3, because we didn't create a placeholder for it (Python 3.6 started raising ModuleNotFoundError, a subclass of ImportError with a different error message than earlier releases so we can't see that directly): .. doctest:: >>> try: ... import zope.deprecation.old_package.m3 ... except ImportError as e: ... print("No module named" in str(e)) ... print("m3" in str(e)) True True Before we move on, let's clean up the temporary modules / packages: .. doctest:: >>> zope.deprecation.__path__.remove(tmp_d) >>> import shutil >>> shutil.rmtree(tmp_d) Temporarily turning off deprecation warnings ============================================ In some cases it is desireable to turn off the deprecation warnings for a short time. To support such a feature, the ``zope.deprecation`` package provides a context manager class, :class:`zope.deprecation.Suppressor`. Code running inside the scope of a ``Suppressor`` will not emit deprecation warnings. .. doctest:: >>> from zope.deprecation import Suppressor >>> class Foo(object): ... bar = property(lambda self: 1) ... bar = deprecation.deprecated(bar, 'bar is no more.') ... blah = property(lambda self: 1) ... blah = deprecation.deprecated(blah, 'blah is no more.') >>> foo = Foo() >>> with Suppressor(): ... foo.blah 1 Note that no warning is emitted when ``foo.blah`` is accessed inside the suppressor's scope.: The suppressor is implemented in terms of a ``__show__`` object. One can ask for its status by calling it: .. doctest:: >>> from zope.deprecation import __show__ >>> __show__() True Inside a suppressor's scope, that status is always false: .. doctest:: >>> with Suppressor(): ... __show__() False .. doctest:: >>> with warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... foo.bar 1 >>> print(log[0].message) bar is no more. If needed, your code can manage the depraction warnings manually using the ``on()`` and ``off()`` methods of the ``__show__`` object: .. doctest:: >>> __show__.off() >>> __show__() False >>> foo.blah 1 Now, you can also nest several turn-offs, so that calling ``off()`` multiple times is meaningful: .. doctest:: >>> __show__.stack [False] >>> __show__.off() >>> __show__.stack [False, False] >>> __show__.on() >>> __show__.stack [False] >>> __show__() False >>> __show__.on() >>> __show__.stack [] >>> __show__() True You can also reset ``__show__`` to ``True``: .. doctest:: >>> __show__.off() >>> __show__.off() >>> __show__() False >>> __show__.reset() >>> __show__() True Finally, you cannot call ``on()`` without having called ``off()`` before: .. doctest:: >>> __show__.on() Traceback (most recent call last): ... IndexError: pop from empty list zope.deprecation-4.4.0/docs/conf.py0000644000076500000240000001740013401230430017734 0ustar jmaddenstaff00000000000000# -*- coding: utf-8 -*- # # zope.deprecation documentation build configuration file, created by # sphinx-quickstart on Thu Apr 19 16:41:59 2012. # # 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. import sys, os # 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. #sys.path.insert(0, os.path.abspath('.')) # -- 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.doctest', 'sphinx.ext.viewcode'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'zope.deprecation' copyright = u'2012, Zope Foundation Contributors' # 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 = '4.0' # The full version, including alpha/beta/rc tags. release = '4.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # -- 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 = 'default' # 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 themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # 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'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'zopedeprecationdoc' # -- 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': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'zopedeprecation.tex', u'zope.deprecation Documentation', u'Zope Foundation Contributors', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'zopedeprecation', u'zope.deprecation Documentation', [u'Zope Foundation Contributors'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- 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 = [ ('index', 'zopedeprecation', u'zope.deprecation Documentation', u'Zope Foundation Contributors', 'zopedeprecation', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' zope.deprecation-4.4.0/docs/hacking.rst0000644000076500000240000002112313401230430020570 0ustar jmaddenstaff00000000000000Hacking on :mod:`zope.deprecation` ================================== Getting the Code ################ The main repository for :mod:`zope.deprecation` is in the Zope Foundation Github repository: https://github.com/zopefoundation/zope.deprecation You can get a read-only checkout from there: .. code-block:: sh $ git clone https://github.com/zopefoundation/zope.deprecation.git or fork it and get a writeable checkout of your fork: .. code-block:: sh $ git clone git@github.com/jrandom/zope.deprecation.git The project also mirrors the trunk from the Github repository as a Bazaar branch on Launchpad: https://code.launchpad.net/zope.deprecation You can branch the trunk from there using Bazaar: .. code-block:: sh $ bzr branch lp:zope.deprecation Working in a ``virtualenv`` ########################### Installing ---------- If you use the ``virtualenv`` package to create lightweight Python development environments, you can run the tests using nothing more than the ``python`` binary in a virtualenv. First, create a scratch environment: .. code-block:: sh $ /path/to/virtualenv --no-site-packages /tmp/hack-zope.deprecation Next, get this package registered as a "development egg" in the environment: .. code-block:: sh $ /tmp/hack-zope.deprecation/bin/python setup.py develop Running the tests ----------------- Run the tests using the build-in ``setuptools`` testrunner: .. code-block:: sh $ /tmp/hack-zope.deprecation/bin/python setup.py test running test .................................................... ---------------------------------------------------------------------- Ran 52 tests in 0.155s OK If you have the :mod:`nose` package installed in the virtualenv, you can use its testrunner too: .. code-block:: sh $ /tmp/hack-zope.deprecation/bin/easy_install nose ... $ /tmp/hack-zope.deprecation/bin/python setup.py nosetests running nosetests .................................................... ---------------------------------------------------------------------- Ran 52 tests in 0.155s OK or: .. code-block:: sh $ /tmp/hack-zope.deprecation/bin/nosetests .................................................... ---------------------------------------------------------------------- Ran 52 tests in 0.155s OK If you have the :mod:`coverage` pacakge installed in the virtualenv, you can see how well the tests cover the code: .. code-block:: sh $ /tmp/hack-zope.deprecation/bin/easy_install nose coverage ... $ /tmp/hack-zope.deprecation/bin/python setup.py nosetests \ --with coverage --cover-package=zope.deprecation running nosetests .................................................... Name Stmts Miss Cover Missing ------------------------------------------------------------ zope.deprecation 7 0 100% zope.deprecation.deprecation 127 0 100% zope.deprecation.fixture 1 0 100% ------------------------------------------------------------ TOTAL 135 0 100% ---------------------------------------------------------------------- Ran 52 tests in 0.155s OK Building the documentation -------------------------- :mod:`zope.deprecation` uses the nifty :mod:`Sphinx` documentation system for building its docs. Using the same virtualenv you set up to run the tests, you can build the docs: .. code-block:: sh $ /tmp/hack-zope.deprecation/bin/easy_install Sphinx ... $ bin/sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html ... build succeeded. You can also test the code snippets in the documentation: .. code-block:: sh $ bin/sphinx-build -b doctest -d docs/_build/doctrees docs docs/_build/doctest ... Doctest summary =============== 89 tests 0 failures in tests 0 failures in setup code build succeeded. Testing of doctests in the sources finished, look at the \ results in _build/doctest/output.txt. Using :mod:`zc.buildout` ######################## Setting up the buildout ----------------------- :mod:`zope.deprecation` ships with its own :file:`buildout.cfg` file and :file:`bootstrap.py` for setting up a development buildout: .. code-block:: sh $ /path/to/python2.6 bootstrap.py ... Generated script '.../bin/buildout' $ bin/buildout Develop: '/home/jrandom/projects/Zope/BTK/deprecation/.' ... Generated script '.../bin/sphinx-quickstart'. Generated script '.../bin/sphinx-build'. Running the tests using ----------------------- Run the tests: .. code-block:: sh $ bin/test --all Running zope.testing.testrunner.layer.UnitTests tests: Set up zope.testing.testrunner.layer.UnitTests in 0.000 seconds. Ran 52 tests with 0 failures and 0 errors in 0.366 seconds. Tearing down left over layers: Tear down zope.testing.testrunner.layer.UnitTests in 0.000 seconds. Using :mod:`tox` ################ Running Tests on Multiple Python Versions ----------------------------------------- `tox `_ is a Python-based test automation tool designed to run tests against multiple Python versions. It creates a ``virtualenv`` for each configured version, installs the current package and configured dependencies into each ``virtualenv``, and then runs the configured commands. :mod:`zope.deprecation` configures the following :mod:`tox` environments via its ``tox.ini`` file: - The ``py26``, ``py27``, ``py33``, ``py34``, and ``pypy`` environments builds a ``virtualenv`` with ``pypy``, installs :mod:`zope.deprecation` and dependencies, and runs the tests via ``python setup.py test -q``. - The ``coverage`` environment builds a ``virtualenv`` with ``python2.6``, installs :mod:`zope.deprecation`, installs :mod:`nose` and :mod:`coverage`, and runs ``nosetests`` with statement coverage. - The ``docs`` environment builds a virtualenv with ``python2.6``, installs :mod:`zope.deprecation`, installs ``Sphinx`` and dependencies, and then builds the docs and exercises the doctest snippets. This example requires that you have a working ``python2.6`` on your path, as well as installing ``tox``: .. code-block:: sh $ tox -e py26 GLOB sdist-make: .../zope.interface/setup.py py26 sdist-reinst: .../zope.interface/.tox/dist/zope.interface-4.0.2dev.zip py26 runtests: commands[0] .......... ---------------------------------------------------------------------- Ran 52 tests in 0.155s OK ___________________________________ summary ____________________________________ py26: commands succeeded congratulations :) Running ``tox`` with no arguments runs all the configured environments, including building the docs and testing their snippets: .. code-block:: sh $ tox GLOB sdist-make: .../zope.interface/setup.py py26 sdist-reinst: .../zope.interface/.tox/dist/zope.interface-4.0.2dev.zip py26 runtests: commands[0] ... Doctest summary =============== 89 tests 0 failures in tests 0 failures in setup code 0 failures in cleanup code build succeeded. ___________________________________ summary ____________________________________ py26: commands succeeded py27: commands succeeded py32: commands succeeded pypy: commands succeeded coverage: commands succeeded docs: commands succeeded congratulations :) Contributing to :mod:`zope.deprecation` ####################################### Submitting a Bug Report ----------------------- :mod:`zope.deprecation` tracks its bugs on Github: https://github.com/zopefoundation/zope.deprecation/issues Please submit bug reports and feature requests there. Sharing Your Changes -------------------- .. note:: Please ensure that all tests are passing before you submit your code. If possible, your submission should include new tests for new features or bug fixes, although it is possible that you may have tested your new code by updating existing tests. If have made a change you would like to share, the best route is to fork the Githb repository, check out your fork, make your changes on a branch in your fork, and push it. You can then submit a pull request from your branch: https://github.com/zopefoundation/zope.deprecation/pulls If you branched the code from Launchpad using Bazaar, you have another option: you can "push" your branch to Launchpad: .. code-block:: sh $ bzr push lp:~jrandom/zope.deprecation/cool_feature After pushing your branch, you can link it to a bug report on Launchpad, or request that the maintainers merge your branch using the Launchpad "merge request" feature. zope.deprecation-4.4.0/docs/index.rst0000644000076500000240000000034613401230430020277 0ustar jmaddenstaff00000000000000:mod:`zope.deprecation` Documentation ===================================== Contents: .. toctree:: :maxdepth: 2 api hacking Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` zope.deprecation-4.4.0/docs/make.bat0000644000076500000240000001177213401230430020050 0ustar jmaddenstaff00000000000000@ECHO OFF REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set BUILDDIR=_build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . set I18NSPHINXOPTS=%SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. singlehtml to make a single large HTML file echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. devhelp to make HTML files and a Devhelp project echo. epub to make an epub echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. text to make text files echo. man to make manual pages echo. texinfo to make Texinfo files echo. gettext to make PO message catalogs echo. changes to make an overview over all changed/added/deprecated items echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "singlehtml" ( %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\zopedeprecation.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\zopedeprecation.ghc goto end ) if "%1" == "devhelp" ( %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp if errorlevel 1 exit /b 1 echo. echo.Build finished. goto end ) if "%1" == "epub" ( %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub if errorlevel 1 exit /b 1 echo. echo.Build finished. The epub file is in %BUILDDIR%/epub. goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex if errorlevel 1 exit /b 1 echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "text" ( %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text if errorlevel 1 exit /b 1 echo. echo.Build finished. The text files are in %BUILDDIR%/text. goto end ) if "%1" == "man" ( %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man if errorlevel 1 exit /b 1 echo. echo.Build finished. The manual pages are in %BUILDDIR%/man. goto end ) if "%1" == "texinfo" ( %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo if errorlevel 1 exit /b 1 echo. echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. goto end ) if "%1" == "gettext" ( %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale if errorlevel 1 exit /b 1 echo. echo.Build finished. The message catalogs are in %BUILDDIR%/locale. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes if errorlevel 1 exit /b 1 echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck if errorlevel 1 exit /b 1 echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest if errorlevel 1 exit /b 1 echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) :end zope.deprecation-4.4.0/setup.cfg0000644000076500000240000000042713401230431017330 0ustar jmaddenstaff00000000000000[nosetests] nocapture = 1 cover-package = zope.deprecation cover-erase = 1 with-doctest = 0 where = src [aliases] dev = develop easy_install zope.deprecation[testing] docs = easy_install zope.deprecation[docs] [bdist_wheel] universal = 1 [egg_info] tag_build = tag_date = 0 zope.deprecation-4.4.0/setup.py0000644000076500000240000000503213401230430017215 0ustar jmaddenstaff00000000000000############################################################################## # # Copyright (c) 2006 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## # This package is developed by the Zope Toolkit project, documented here: # http://docs.zope.org/zopetoolkit # When developing and releasing this package, please follow the documented # Zope Toolkit policies as described by this documentation. ############################################################################## """Setup for zope.deprecation package """ import os from setuptools import setup, find_packages def read(*rnames): with open(os.path.join(os.path.dirname(__file__), *rnames)) as f: return f.read() setup( name='zope.deprecation', version='4.4.0', url='https://github.com/zopefoundation/zope.deprecation', license='ZPL 2.1', description='Zope Deprecation Infrastructure', author='Zope Corporation and Contributors', author_email='zope-dev@zope.org', long_description=( read('README.rst') + '\n\n' + read('CHANGES.rst') ), keywords=["deprecation", "deprecated", "warning"], classifiers=[ "Intended Audience :: Developers", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Framework :: Zope :: 3", ], package_dir={'': 'src'}, packages=find_packages('src'), namespace_packages=['zope',], install_requires=[ 'setuptools', ], include_package_data=True, zip_safe=False, test_suite='zope.deprecation', extras_require={ 'docs': ['Sphinx'], 'test': [ 'zope.testrunner', ], }, ) zope.deprecation-4.4.0/src/0000755000076500000240000000000013401230431016273 5ustar jmaddenstaff00000000000000zope.deprecation-4.4.0/src/zope/0000755000076500000240000000000013401230431017250 5ustar jmaddenstaff00000000000000zope.deprecation-4.4.0/src/zope/__init__.py0000644000076500000240000000011313401230430021353 0ustar jmaddenstaff00000000000000__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover zope.deprecation-4.4.0/src/zope/deprecation/0000755000076500000240000000000013401230431021545 5ustar jmaddenstaff00000000000000zope.deprecation-4.4.0/src/zope/deprecation/__init__.py0000644000076500000240000000176613401230430023667 0ustar jmaddenstaff00000000000000############################################################################## # # Copyright (c) 2005 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Deprecation of modules / APIs. """ __docformat__ = "reStructuredText" from zope.deprecation.deprecation import deprecated from zope.deprecation.deprecation import deprecate from zope.deprecation.deprecation import moved from zope.deprecation.deprecation import ShowSwitch from zope.deprecation.deprecation import __show__ from zope.deprecation.deprecation import Suppressor zope.deprecation-4.4.0/src/zope/deprecation/deprecation.py0000644000076500000240000001576713401230430024433 0ustar jmaddenstaff00000000000000############################################################################## # # Copyright (c) 2005 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Deprecation Support This module provides utilities to ease the development of backward-compatible code. """ __docformat__ = "reStructuredText" import sys import types import warnings str_and_sequence_types = (str if str is not bytes else basestring, list, tuple) class ShowSwitch(object): """Simple stack-based switch.""" def __init__(self): self.stack = [] def on(self): self.stack.pop() def off(self): self.stack.append(False) def reset(self): self.stack = [] def __call__(self): return self.stack == [] def __repr__(self): return '' %(self() and 'on' or 'off') # This attribute can be used to temporarly deactivate deprecation # warnings, so that backward-compatibility code can import other # backward-compatiblity components without warnings being produced. __show__ = ShowSwitch() class Suppressor(object): def __enter__(self): __show__.off() def __exit__(self, *ignored): __show__.on() ogetattr = object.__getattribute__ class DeprecationProxy(object): def __init__(self, module): self.__original_module = module self.__deprecated = {} def deprecate(self, names, message, cls=DeprecationWarning): """Deprecate the given names.""" if not isinstance(names, (tuple, list)): names = (names,) for name in names: self.__deprecated[name] = (message, cls) def __getattribute__(self, name): if name == 'deprecate' or name.startswith('_DeprecationProxy__'): return ogetattr(self, name) if name == '__class__': return types.ModuleType if name in ogetattr(self, '_DeprecationProxy__deprecated'): if __show__(): msg, cls = self.__deprecated[name] warnings.warn(name + ': ' + msg, cls, 2) return getattr(ogetattr(self, '_DeprecationProxy__original_module'), name) def __setattr__(self, name, value): if name.startswith('_DeprecationProxy__'): return object.__setattr__(self, name, value) setattr(self.__original_module, name, value) def __delattr__(self, name): if name.startswith('_DeprecationProxy__'): return object.__delattr__(self, name) delattr(self.__original_module, name) class DeprecatedModule(object): def __init__(self, module, msg, cls=DeprecationWarning): self.__original_module = module self.__msg = msg self.__cls = cls def __getattribute__(self, name): if name.startswith('_DeprecatedModule__'): return ogetattr(self, name) if name == '__class__': return types.ModuleType if __show__(): warnings.warn(self.__msg, self.__cls, 2) return getattr(ogetattr(self, '_DeprecatedModule__original_module'), name) def __setattr__(self, name, value): if name.startswith('_DeprecatedModule__'): return object.__setattr__(self, name, value) setattr(self.__original_module, name, value) def __delattr__(self, name): if name.startswith('_DeprecatedModule__'): return object.__delattr__(self, name) delattr(self.__original_module, name) class DeprecatedGetProperty(object): def __init__(self, prop, message, cls=DeprecationWarning): self.message = message self.prop = prop self.cls = cls def __get__(self, inst, klass): if __show__(): warnings.warn(self.message, self.cls, 2) return self.prop.__get__(inst, klass) class DeprecatedGetSetProperty(DeprecatedGetProperty): def __set__(self, inst, prop): if __show__(): warnings.warn(self.message, self.cls, 2) self.prop.__set__(inst, prop) class DeprecatedGetSetDeleteProperty(DeprecatedGetSetProperty): def __delete__(self, inst): if __show__(): warnings.warn(self.message, self.cls, 2) self.prop.__delete__(inst) def DeprecatedMethod(method, message, cls=DeprecationWarning): def deprecated_method(*args, **kw): if __show__(): warnings.warn(message, cls, 2) return method(*args, **kw) return deprecated_method def deprecated(specifier, message, cls=DeprecationWarning): """Deprecate the given names.""" # A string specifier (or list of strings) means we're called # top-level in a module and are to deprecate things inside this # module if isinstance(specifier, str_and_sequence_types): globals = sys._getframe(1).f_globals modname = globals['__name__'] if not isinstance(sys.modules[modname], DeprecationProxy): sys.modules[modname] = DeprecationProxy(sys.modules[modname]) sys.modules[modname].deprecate(specifier, message, cls) # Anything else can mean the specifier is a function/method, # module, or just an attribute of a class elif isinstance(specifier, types.FunctionType): return DeprecatedMethod(specifier, message, cls) elif isinstance(specifier, types.ModuleType): return DeprecatedModule(specifier, message, cls) else: prop = specifier if hasattr(prop, '__get__') and hasattr(prop, '__set__') and \ hasattr(prop, '__delete__'): return DeprecatedGetSetDeleteProperty(prop, message, cls) elif hasattr(prop, '__get__') and hasattr(prop, '__set__'): return DeprecatedGetSetProperty(prop, message, cls) elif hasattr(prop, '__get__'): return DeprecatedGetProperty(prop, message, cls) class deprecate(object): """Deprecation decorator""" def __init__(self, msg, cls=DeprecationWarning): self.msg = msg self.cls = cls def __call__(self, func): return DeprecatedMethod(func, self.msg, self.cls) def moved(to_location, unsupported_in=None, cls=DeprecationWarning): old = sys._getframe(1).f_globals['__name__'] message = '%s has moved to %s.' % (old, to_location) if unsupported_in: message += " Import of %s will become unsupported in %s" % ( old, unsupported_in) warnings.warn(message, cls, 3) __import__(to_location) fromdict = sys.modules[to_location].__dict__ tomod = sys.modules[old] tomod.__doc__ = message for name, v in fromdict.items(): if name not in tomod.__dict__: setattr(tomod, name, v) zope.deprecation-4.4.0/src/zope/deprecation/fixture.py0000644000076500000240000000003213401230430023577 0ustar jmaddenstaff00000000000000# used by tests abc = 1 zope.deprecation-4.4.0/src/zope/deprecation/tests.py0000644000076500000240000005015513401230430023266 0ustar jmaddenstaff00000000000000import sys import types import unittest class TestShowSwitch(unittest.TestCase): def _makeOne(self): from zope.deprecation import ShowSwitch return ShowSwitch() def test_on(self): switch = self._makeOne() switch.stack.append(False) switch.on() self.assertEqual(switch.stack, []) def test_off(self): switch = self._makeOne() switch.off() self.assertEqual(switch.stack, [False]) def test_reset(self): switch = self._makeOne() switch.stack.append(False) switch.reset() self.assertEqual(switch.stack, []) def test_call_true(self): switch = self._makeOne() self.assertEqual(switch(), True) def test_call_false(self): switch = self._makeOne() switch.stack.append(False) self.assertEqual(switch(), False) def test_repr_on(self): switch = self._makeOne() self.assertEqual(repr(switch), '') def test_repr_off(self): switch = self._makeOne() switch.stack.append(False) self.assertEqual(repr(switch), '') def test___show__global(self): from zope.deprecation import __show__ self.assertEqual(self._makeOne().__class__, __show__.__class__) class TestSuppressor(unittest.TestCase): def _makeOne(self): from zope.deprecation import Suppressor return Suppressor() def test_it(self): from zope.deprecation import __show__ self.assertEqual(__show__.stack, []) with self._makeOne(): self.assertEqual(__show__.stack, [False]) self.assertEqual(__show__.stack, []) class WarningsSetupBase(object): def setUp(self): from zope.deprecation import deprecation self.oldwarnings = deprecation.warnings self.oldshow = deprecation.__show__ self.warnings = DummyWarningsModule() self.show = DummyShow() deprecation.warnings = self.warnings deprecation.__show__ = self.show def tearDown(self): from zope.deprecation import deprecation deprecation.warnings = self.oldwarnings deprecation.__show__ = self.oldshow class TestDeprecationProxy(WarningsSetupBase, unittest.TestCase): def _getTargetClass(self): from zope.deprecation.deprecation import DeprecationProxy return DeprecationProxy def _makeOne(self, module): cls = self._getTargetClass() return cls(module) def test_deprecate_and__getattribute__string(self): tests = _getTestsModule() proxy = self._makeOne(tests) proxy.deprecate('ClassFixture', 'hello') self.assertEqual(proxy.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, [('ClassFixture: hello', DeprecationWarning, 2)]) def test_deprecate_and__getattribute__string_with_custom_cls(self): tests = _getTestsModule() proxy = self._makeOne(tests) proxy.deprecate('ClassFixture', 'hello', DummyWarning) self.assertEqual(proxy.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, [('ClassFixture: hello', DummyWarning, 2)]) def test_deprecate_and__getattribute__sequence(self): tests = _getTestsModule() proxy = self._makeOne(tests) proxy.deprecate(('ClassFixture', 'ClassFixture2'), 'hello') self.assertEqual(proxy.ClassFixture, ClassFixture) self.assertEqual(proxy.ClassFixture2, ClassFixture2) self.assertEqual( self.warnings.w, [('ClassFixture: hello', DeprecationWarning, 2), ('ClassFixture2: hello', DeprecationWarning, 2)] ) def test_deprecate_and__getattribute__noshow(self): tests = _getTestsModule() proxy = self._makeOne(tests) proxy.deprecate('ClassFixture', 'hello') self.show.on = False self.assertEqual(proxy.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, []) def test___getattribute____class__(self): tests = _getTestsModule() proxy = self._makeOne(tests) self.assertEqual(proxy.__class__, types.ModuleType) def test___getattribute___deprecate(self): tests = _getTestsModule() proxy = self._makeOne(tests) self.assertEqual(type(proxy.deprecate), types.MethodType) def test___getattribute__missing(self): tests = _getTestsModule() proxy = self._makeOne(tests) self.assertRaises(AttributeError, getattr, proxy, 'wontbethere') def test___setattr__owned(self): tests = _getTestsModule() proxy = self._makeOne(tests) proxy._DeprecationProxy__deprecated = {'foo':'bar'} self.assertEqual(proxy._DeprecationProxy__deprecated, {'foo':'bar'}) def test___setattr__notowned(self): tests = _getTestsModule() proxy = self._makeOne(tests) try: proxy.foo = 'bar' self.assertEqual(tests.foo, 'bar') finally: del tests.foo def test___delattr__owned(self): tests = _getTestsModule() proxy = self._makeOne(tests) del proxy._DeprecationProxy__deprecated self.assertRaises(AttributeError, getattr, proxy, '_DeprecationProxy__deprecated') def test___delattr__notowned(self): tests = _getTestsModule() proxy = self._makeOne(tests) tests.foo = 'bar' del proxy.foo self.assertRaises(AttributeError, getattr, tests, 'foo') class TestDeprecatedModule(WarningsSetupBase, unittest.TestCase): def _getTargetClass(self): from zope.deprecation.deprecation import DeprecatedModule return DeprecatedModule def _makeOne(self, module, msg, *args): cls = self._getTargetClass() return cls(module, msg, *args) def test___getattribute____class__(self): tests = _getTestsModule() proxy = self._makeOne(tests, 'hello') self.assertEqual(proxy.__class__, types.ModuleType) def test___getattribute____owned__(self): tests = _getTestsModule() proxy = self._makeOne(tests, 'hello') self.assertEqual(proxy._DeprecatedModule__msg, 'hello') def test___getattribute___deprecated(self): tests = _getTestsModule() proxy = self._makeOne(tests, 'hello') self.assertEqual(proxy.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)] ) def test___getattribute___deprecated_with_custom_cls(self): tests = _getTestsModule() proxy = self._makeOne(tests, 'hello', DummyWarning) self.assertEqual(proxy.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, [('hello', DummyWarning, 2)] ) def test___getattribute__missing(self): tests = _getTestsModule() proxy = self._makeOne(tests, 'hello') self.assertRaises(AttributeError, getattr, proxy, 'wontbethere') self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)] ) def test___getattribute___noshow(self): tests = _getTestsModule() self.show.on = False proxy = self._makeOne(tests, 'hello') self.assertEqual(proxy.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, []) def test___setattr__owned(self): tests = _getTestsModule() proxy = self._makeOne(tests, 'hello') proxy._DeprecatedModule__msg = 'foo' self.assertEqual(proxy._DeprecatedModule__msg, 'foo') def test___setattr__notowned(self): tests = _getTestsModule() proxy = self._makeOne(tests, 'hello') try: proxy.foo = 'bar' self.assertEqual(tests.foo, 'bar') finally: del tests.foo def test___delattr__owned(self): tests = _getTestsModule() proxy = self._makeOne(tests, 'hello') del proxy._DeprecatedModule__msg self.assertRaises(AttributeError, getattr, proxy, '_DeprecatedModule__msg') def test___delattr__notowned(self): tests = _getTestsModule() proxy = self._makeOne(tests, 'hello') tests.foo = 'bar' del proxy.foo self.assertRaises(AttributeError, getattr, tests, 'foo') class TestDeprecatedGetProperty(WarningsSetupBase, unittest.TestCase): def _getTargetClass(self): from zope.deprecation.deprecation import DeprecatedGetProperty return DeprecatedGetProperty def _makeOne(self, prop, msg, *args): cls = self._getTargetClass() return cls(prop, msg, *args) def test___get__(self): prop = DummyProperty() proxy = self._makeOne(prop, 'hello') self.assertEqual(proxy.__get__('inst', 'cls'), None) self.assertEqual(prop.inst, 'inst') self.assertEqual(prop.cls, 'cls') self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)] ) def test___get___with_custom_cls(self): prop = DummyProperty() proxy = self._makeOne(prop, 'hello', DummyWarning) self.assertEqual(proxy.__get__('inst', 'cls'), None) self.assertEqual(prop.inst, 'inst') self.assertEqual(prop.cls, 'cls') self.assertEqual( self.warnings.w, [('hello', DummyWarning, 2)] ) def test___get__noshow(self): prop = DummyProperty() self.show.on = False proxy = self._makeOne(prop, 'hello') self.assertEqual(proxy.__get__('inst', 'cls'), None) self.assertEqual(prop.inst, 'inst') self.assertEqual(prop.cls, 'cls') self.assertEqual(self.warnings.w, []) class TestDeprecatedGetSetProperty(TestDeprecatedGetProperty): def _getTargetClass(self): from zope.deprecation.deprecation import DeprecatedGetSetProperty return DeprecatedGetSetProperty def test___set__(self): prop = DummyProperty() proxy = self._makeOne(prop, 'hello') self.assertEqual(proxy.__set__('inst', 'prop'), None) self.assertEqual(prop.inst, 'inst') self.assertEqual(prop.prop, 'prop') self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)] ) def test___set___with_custom_cls(self): prop = DummyProperty() proxy = self._makeOne(prop, 'hello', DummyWarning) self.assertEqual(proxy.__set__('inst', 'prop'), None) self.assertEqual(prop.inst, 'inst') self.assertEqual(prop.prop, 'prop') self.assertEqual( self.warnings.w, [('hello', DummyWarning, 2)] ) def test___set__noshow(self): prop = DummyProperty() self.show.on = False proxy = self._makeOne(prop, 'hello') self.assertEqual(proxy.__set__('inst', 'prop'), None) self.assertEqual(prop.inst, 'inst') self.assertEqual(prop.prop, 'prop') self.assertEqual(self.warnings.w, []) class TestDeprecatedSetGetDeleteProperty(TestDeprecatedGetSetProperty): def _getTargetClass(self): from zope.deprecation.deprecation import DeprecatedGetSetDeleteProperty return DeprecatedGetSetDeleteProperty def test___delete__(self): prop = DummyProperty() proxy = self._makeOne(prop, 'hello') self.assertEqual(proxy.__delete__('inst'), None) self.assertEqual(prop.inst, 'inst') self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)] ) def test___delete___with_custom_cls(self): prop = DummyProperty() proxy = self._makeOne(prop, 'hello', DummyWarning) self.assertEqual(proxy.__delete__('inst'), None) self.assertEqual(prop.inst, 'inst') self.assertEqual( self.warnings.w, [('hello', DummyWarning, 2)] ) def test___delete__noshow(self): prop = DummyProperty() proxy = self._makeOne(prop, 'hello') self.assertEqual(proxy.__delete__('inst'), None) self.assertEqual(prop.inst, 'inst') self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)] ) class TestDeprecatedMethod(WarningsSetupBase, unittest.TestCase): def _callFUT(self, method, message, *args): from zope.deprecation.deprecation import DeprecatedMethod return DeprecatedMethod(method, message, *args) def fixture(self, a, b, c=1): return 'fixture' def test_it(self): result = self._callFUT(self.fixture, 'hello') self.assertEqual(result('a', 'b', c=2), 'fixture') self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)] ) def test_it_with_custom_cls(self): result = self._callFUT(self.fixture, 'hello', DummyWarning) self.assertEqual(result('a', 'b', c=2), 'fixture') self.assertEqual( self.warnings.w, [('hello', DummyWarning, 2)] ) def test_it_noshow(self): result = self._callFUT(self.fixture, 'hello') self.show.on = False self.assertEqual(result('a', 'b', c=2), 'fixture') self.assertEqual(self.warnings.w, []) class Test_deprecated(WarningsSetupBase, unittest.TestCase): def setUp(self): super(Test_deprecated, self).setUp() self.mod = _getTestsModule() def tearDown(self): super(Test_deprecated, self).tearDown() sys.modules['zope.deprecation.tests'] = self.mod def _callFUT(self, spec, message, *args): from zope.deprecation.deprecation import deprecated return deprecated(spec, message, *args) def test_string_specifier(self): self._callFUT('ClassFixture', 'hello') mod = _getTestsModule() self.assertNotEqual(mod, self.mod) self.assertEqual(mod.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, [('ClassFixture: hello', DeprecationWarning, 2)]) def test_string_specifier_with_custom_cls(self): self._callFUT('ClassFixture', 'hello', DummyWarning) mod = _getTestsModule() self.assertNotEqual(mod, self.mod) self.assertEqual(mod.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, [('ClassFixture: hello', DummyWarning, 2)]) def test_string_specifier_sys_modules_already_mutated(self): from zope.deprecation.deprecation import DeprecationProxy mod = _getTestsModule() new = sys.modules['zope.deprecation.tests'] = DeprecationProxy(mod) self._callFUT('ClassFixture', 'hello') self.assertEqual(new.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, [('ClassFixture: hello', DeprecationWarning, 2)]) def test_function_specifier(self): result = self._callFUT(functionfixture, 'hello') self.assertNotEqual(result, functionfixture) self.assertEqual(self.warnings.w, []) result() self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)]) def test_module_specifier(self): mod = _getTestsModule() result = self._callFUT(mod, 'hello') self.assertEqual(self.warnings.w, []) self.assertEqual(result.ClassFixture, ClassFixture) self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)]) def test_getproperty_specifier(self): prop = DummyGetProperty() result = self._callFUT(prop, 'hello') self.assertEqual(self.warnings.w, []) self.assertEqual(result.__get__('inst', 'cls'), None) self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)]) def test_getsetproperty_specifier(self): prop = DummyGetSetProperty() result = self._callFUT(prop, 'hello') self.assertEqual(self.warnings.w, []) self.assertEqual(result.__set__('inst', 'prop'), None) self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)]) def test_getsetdeleteproperty_specifier(self): prop = DummyGetSetDeleteProperty() result = self._callFUT(prop, 'hello') self.assertEqual(self.warnings.w, []) self.assertEqual(result.__delete__('inst'), None) self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)]) class Test_deprecate(WarningsSetupBase, unittest.TestCase): def _getTargetClass(self): from zope.deprecation.deprecation import deprecate return deprecate def _makeOne(self, msg, *args): cls = self._getTargetClass() return cls(msg, *args) def fixture(self): return 42 def test___call__(self): proxy = self._makeOne('hello') result = proxy(functionfixture) self.assertEqual(result(), None) self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 2)]) def test___call__method(self): proxy = self._makeOne('method') result = proxy(self.fixture) self.assertEqual(result(), 42) self.assertEqual( self.warnings.w, [('method', DeprecationWarning, 2)]) def test___call__with_custom_cls(self): proxy = self._makeOne('hello', DummyWarning) result = proxy(functionfixture) self.assertEqual(result(), None) self.assertEqual( self.warnings.w, [('hello', DummyWarning, 2)]) class Test_moved(WarningsSetupBase, unittest.TestCase): def setUp(self): super(Test_moved, self).setUp() def tearDown(self): super(Test_moved, self).tearDown() del _getTestsModule().__dict__['abc'] def _callFUT(self, to_location, unsupported_in, *args): from zope.deprecation.deprecation import moved return moved(to_location, unsupported_in, *args) def test_unsupported_None(self): self._callFUT('zope.deprecation.fixture', None) self.assertEqual( self.warnings.w, [('zope.deprecation.tests has moved to zope.deprecation.fixture.', DeprecationWarning, 3)]) def test_unsupported_None_with_custom_cls(self): self._callFUT('zope.deprecation.fixture', None, DummyWarning) self.assertEqual( self.warnings.w, [('zope.deprecation.tests has moved to zope.deprecation.fixture.', DummyWarning, 3)]) def test_unsupported_not_None(self): self._callFUT('zope.deprecation.fixture', '1.3') self.assertEqual( self.warnings.w, [('zope.deprecation.tests has moved to zope.deprecation.fixture. ' 'Import of zope.deprecation.tests will become unsupported in 1.3', DeprecationWarning, 3)]) class Test_import_aliases(unittest.TestCase): def test_it(self): for name in ('deprecated', 'deprecate', 'moved', 'ShowSwitch', '__show__'): real = getattr(sys.modules['zope.deprecation.deprecation'], name) alias = getattr(sys.modules['zope.deprecation'], name) self.assertEqual(real, alias, (real, alias)) class DummyWarningsModule(object): def __init__(self): self.w = [] def warn(self, msg, type, stacklevel): self.w.append((msg, type, stacklevel)) class DummyGetProperty(object): def __get__(self, inst, cls): self.inst = inst self.cls = cls class DummyGetSetProperty(DummyGetProperty): def __set__(self, inst, prop): self.inst = inst self.prop = prop class DummyGetSetDeleteProperty(DummyGetSetProperty): def __delete__(self, inst): self.inst = inst class DummyWarning(DeprecationWarning): pass DummyProperty = DummyGetSetDeleteProperty def _getTestsModule(): __import__('zope.deprecation.tests') return sys.modules['zope.deprecation.tests'] class DummyShow(object): def __init__(self): self.on = True def __call__(self): if self.on: return True return False class ClassFixture(object): pass class ClassFixture2(object): pass def functionfixture(): pass zope.deprecation-4.4.0/src/zope.deprecation.egg-info/0000755000076500000240000000000013401230431023236 5ustar jmaddenstaff00000000000000zope.deprecation-4.4.0/src/zope.deprecation.egg-info/PKG-INFO0000644000076500000240000001336013401230431024336 0ustar jmaddenstaff00000000000000Metadata-Version: 2.1 Name: zope.deprecation Version: 4.4.0 Summary: Zope Deprecation Infrastructure Home-page: https://github.com/zopefoundation/zope.deprecation Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Description: ====================== ``zope.deprecation`` ====================== .. image:: https://img.shields.io/pypi/v/zope.deprecation.svg :target: https://pypi.python.org/pypi/zope.deprecation/ :alt: Latest release .. image:: https://img.shields.io/pypi/pyversions/zope.deprecation.svg :target: https://pypi.org/project/zope.deprecation/ :alt: Supported Python versions .. image:: https://travis-ci.org/zopefoundation/zope.deprecation.svg?branch=master :target: https://travis-ci.org/zopefoundation/zope.deprecation .. image:: https://coveralls.io/repos/github/zopefoundation/zope.deprecation/badge.svg?branch=master :target: https://coveralls.io/github/zopefoundation/zope.deprecation?branch=master .. image:: https://readthedocs.org/projects/zopedeprecation/badge/?version=latest :target: https://zopedeprecation.readthedocs.io/en/latest/ :alt: Documentation Status This package provides a simple function called ``deprecated(names, reason)`` to mark deprecated modules, classes, functions, methods and properties. Please see https://zopedeprecation.readthedocs.io for the documentation. ================================ ``zope.deprecation`` Changelog ================================ 4.4.0 (2018-12-03) ================== - Add support for Python 3.7. 4.3.0 (2017-08-07) ================== - Allow custom warning classes to be specified to override the default ``DeprecationWarning``. See https://github.com/zopefoundation/zope.deprecation/pull/7 - Add support for Python 3.6. - Drop support for Python 3.3. 4.2.0 (2016-11-07) ================== - Drop support for Python 2.6 and 3.2. - Add support for Python 3.5. 4.1.2 (2015-01-13) ================== - Do not require a ``self`` parameter for deprecated functions. See: https://github.com/zopefoundation/zope.deprecation/pull/1 4.1.1 (2014-03-19) ================== - Added explicit support for Python 3.4. 4.1.0 (2013-12-20) ================== - Added a ``Suppressor`` context manager, allowing scoped suppression of deprecation warnings. - Updated ``boostrap.py`` to version 2.2. 4.0.2 (2012-12-31) ================== - Fleshed out PyPI Trove classifiers. 4.0.1 (2012-11-21) ================== - Added support for Python 3.3. 4.0.0 (2012-05-16) ================== - Automated build of Sphinx HTML docs and running doctest snippets via tox. - Added Sphinx documentation: - API docs moved from package-data README into ``docs/api.rst``. - Snippets can be tested by running 'make doctest'. - Updated support for continuous integration using ``tox`` and ``jenkins``. - 100% unit test coverage. - Added ``setup.py dev`` alias (runs ``setup.py develop`` plus installs ``nose`` and ``coverage``). - Added ``setup.py docs`` alias (installs ``Sphinx`` and dependencies). - Removed spurious dependency on ``zope.testing``. - Dropped explicit support for Python 2.4 / 2.5 / 3.1. 3.5.1 (2012-03-15) ================== - Revert a move of `README.txt` to unbreak ``zope.app.apidoc``. 3.5.0 (2011-09-05) ================== - Replaced doctesting with unit testing. - Python 3 compatibility. 3.4.1 (2011-06-07) ================== - Removed import cycle for ``__show__`` by defining it in the ``zope.deprecation.deprecation`` module. - Added support to bootstrap on Jython. - Fix ``zope.deprecation.warn()`` to make the signature identical to ``warnings.warn()`` and to check for .pyc and .pyo files. 3.4.0 (2007-07-19) ================== - Release 3.4 final, corresponding to Zope 3.4. 3.3.0 (2007-02-18) ================== - Corresponds to the version of the ``zope.deprecation`` package shipped as part of the Zope 3.3.0 release. Keywords: deprecation,deprecated,warning Platform: UNKNOWN Classifier: Intended Audience :: Developers Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Framework :: Zope :: 3 Provides-Extra: docs Provides-Extra: test zope.deprecation-4.4.0/src/zope.deprecation.egg-info/SOURCES.txt0000644000076500000240000000131213401230431025117 0ustar jmaddenstaff00000000000000.coveragerc .travis.yml CHANGES.rst COPYRIGHT.txt LICENSE.txt MANIFEST.in README.rst bootstrap.py buildout.cfg setup.cfg setup.py tox.ini docs/Makefile docs/api.rst docs/conf.py docs/hacking.rst docs/index.rst docs/make.bat docs/_static/.gitignore src/zope/__init__.py src/zope.deprecation.egg-info/PKG-INFO src/zope.deprecation.egg-info/SOURCES.txt src/zope.deprecation.egg-info/dependency_links.txt src/zope.deprecation.egg-info/namespace_packages.txt src/zope.deprecation.egg-info/not-zip-safe src/zope.deprecation.egg-info/requires.txt src/zope.deprecation.egg-info/top_level.txt src/zope/deprecation/__init__.py src/zope/deprecation/deprecation.py src/zope/deprecation/fixture.py src/zope/deprecation/tests.pyzope.deprecation-4.4.0/src/zope.deprecation.egg-info/dependency_links.txt0000644000076500000240000000000113401230431027304 0ustar jmaddenstaff00000000000000 zope.deprecation-4.4.0/src/zope.deprecation.egg-info/namespace_packages.txt0000644000076500000240000000000513401230431027564 0ustar jmaddenstaff00000000000000zope zope.deprecation-4.4.0/src/zope.deprecation.egg-info/not-zip-safe0000644000076500000240000000000113401230431025464 0ustar jmaddenstaff00000000000000 zope.deprecation-4.4.0/src/zope.deprecation.egg-info/requires.txt0000644000076500000240000000006213401230431025634 0ustar jmaddenstaff00000000000000setuptools [docs] Sphinx [test] zope.testrunner zope.deprecation-4.4.0/src/zope.deprecation.egg-info/top_level.txt0000644000076500000240000000000513401230431025763 0ustar jmaddenstaff00000000000000zope zope.deprecation-4.4.0/tox.ini0000644000076500000240000000110313401230430017011 0ustar jmaddenstaff00000000000000[tox] envlist = py27,py34,py35,py36,py37,pypy,pypy3,docs [testenv] usedevelop = true commands = coverage run -m zope.testrunner --test-path=src [] coverage run -a -m sphinx -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest coverage report -i --fail-under=100 deps = .[test,docs] coverage setenv = COVERAGE_FILE=.coverage.{envname} [testenv:docs] basepython = python2.7 commands = sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html sphinx-build -b doctest -d docs/_build/doctrees docs docs/_build/doctest