zope.deprecation-4.0.2/0000775000175000017500000000000012070355010014665 5ustar tseavertseaverzope.deprecation-4.0.2/setup.cfg0000644000175000017500000000041712070355010016506 0ustar tseavertseaver[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 [nosetests] cover-package = zope.deprecation nocapture = 1 cover-erase = 1 with-doctest = 0 where = src [aliases] dev = develop easy_install zope.deprecation[testing] docs = easy_install zope.deprecation[docs] zope.deprecation-4.0.2/buildout.cfg0000644000175000017500000000014411744110542017200 0ustar tseavertseaver[buildout] parts = test develop = . [test] recipe = zc.recipe.testrunner eggs = zope.deprecation zope.deprecation-4.0.2/PKG-INFO0000664000175000017500000000656012070355010015771 0ustar tseavertseaverMetadata-Version: 1.0 Name: zope.deprecation Version: 4.0.2 Summary: Zope Deprecation Infrastructure Home-page: http://pypi.python.org/pypi/zope.deprecation Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Description: ``zope.deprecation`` README =========================== This package provides a simple function called ``deprecated(names, reason)`` to mark deprecated modules, classes, functions, methods and properties. Please see http://docs.zope.org/zope.deprecation/ for the documentation. ``zope.deprecation`` Changelog ============================== 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. Platform: UNKNOWN Classifier: Intended Audience :: Developers Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.2 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Framework :: Zope3 zope.deprecation-4.0.2/tox.ini0000644000175000017500000000171312053206477016215 0ustar tseavertseaver[tox] envlist = # Jython support pending 2.7 support, due 2012-07-15 or so. See: # http://fwierzbicki.blogspot.com/2012/03/adconion-to-fund-jython-27.html # py26,py27,py32,jython,pypy,coverage py26,py27,py32,py33,pypy,coverage,docs [testenv] commands = python setup.py test -q [testenv:jython] commands = jython setup.py test -q [testenv:coverage] basepython = python2.6 commands = # The installed version messes up nose's test discovery / coverage reporting # So, we uninstall that from the environment, and then install the editable # version, before running nosetests. pip uninstall -y zope.deprecation pip install -e . nosetests --with-xunit --with-xcoverage deps = nose coverage nosexcover [testenv:docs] basepython = python2.6 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 deps = Sphinx zope.deprecation-4.0.2/setup.py0000644000175000017500000000457712070354763016430 0ustar tseavertseaver############################################################################## # # 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): return open(os.path.join(os.path.dirname(__file__), *rnames)).read() setup( name='zope.deprecation', version='4.0.2', url='http://pypi.python.org/pypi/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.txt') + '\n\n' + read('CHANGES.txt') ), classifiers=[ "Intended Audience :: Developers", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Framework :: Zope3", ], 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'], 'testing': ['nose', 'coverage'], }, ) zope.deprecation-4.0.2/bootstrap.py0000644000175000017500000002352211737604172017275 0ustar tseavertseaver############################################################################## # # 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, shutil, sys, tempfile, textwrap, urllib, urllib2, subprocess from optparse import OptionParser if sys.platform == 'win32': def quote(c): if ' ' in c: return '"%s"' % c # work around spawn lamosity on windows else: return c else: quote = str # See zc.buildout.easy_install._has_broken_dash_S for motivation and comments. stdout, stderr = subprocess.Popen( [sys.executable, '-Sc', 'try:\n' ' import ConfigParser\n' 'except ImportError:\n' ' print 1\n' 'else:\n' ' print 0\n'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() has_broken_dash_S = bool(int(stdout.strip())) # In order to be more robust in the face of system Pythons, we want to # run without site-packages loaded. This is somewhat tricky, in # particular because Python 2.6's distutils imports site, so starting # with the -S flag is not sufficient. However, we'll start with that: if not has_broken_dash_S and 'site' in sys.modules: # We will restart with python -S. args = sys.argv[:] args[0:0] = [sys.executable, '-S'] args = map(quote, args) os.execv(sys.executable, args) # Now we are running with -S. We'll get the clean sys.path, import site # because distutils will do it later, and then reset the path and clean # out any namespace packages from site-packages that might have been # loaded by .pth files. clean_path = sys.path[:] import site sys.path[:] = clean_path for k, v in sys.modules.items(): if k in ('setuptools', 'pkg_resources') or ( hasattr(v, '__path__') and len(v.__path__)==1 and not os.path.exists(os.path.join(v.__path__[0],'__init__.py'))): # This is a namespace package. Remove it. sys.modules.pop(k) is_jython = sys.platform.startswith('java') setuptools_source = 'http://peak.telecommunity.com/dist/ez_setup.py' distribute_source = 'http://python-distribute.org/distribute_setup.py' # parsing arguments def normalize_to_url(option, opt_str, value, parser): if value: if '://' not in value: # It doesn't smell like a URL. value = 'file://%s' % ( urllib.pathname2url( os.path.abspath(os.path.expanduser(value))),) if opt_str == '--download-base' and not value.endswith('/'): # Download base needs a trailing slash to make the world happy. value += '/' else: value = None name = opt_str[2:].replace('-', '_') setattr(parser.values, name, value) 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 --setup-source and --download-base to point to local resources, you can keep this script from going over the network. ''' parser = OptionParser(usage=usage) parser.add_option("-v", "--version", dest="version", help="use a specific zc.buildout version") parser.add_option("-d", "--distribute", action="store_true", dest="use_distribute", default=False, help="Use Distribute rather than Setuptools.") parser.add_option("--setup-source", action="callback", dest="setup_source", callback=normalize_to_url, nargs=1, type="string", help=("Specify a URL or file location for the setup file. " "If you use Setuptools, this will default to " + setuptools_source + "; if you use Distribute, this " "will default to " + distribute_source +".")) parser.add_option("--download-base", action="callback", dest="download_base", callback=normalize_to_url, nargs=1, type="string", help=("Specify a URL or directory for downloading " "zc.buildout and either Setuptools or Distribute. " "Defaults to PyPI.")) parser.add_option("--eggs", help=("Specify a directory for storing eggs. Defaults to " "a temporary directory that is deleted when the " "bootstrap script completes.")) 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", None, action="store", dest="config_file", help=("Specify the path to the buildout configuration " "file to be used.")) options, args = parser.parse_args() # if -c was provided, we push it back into args for buildout's main function if options.config_file is not None: args += ['-c', options.config_file] if options.eggs: eggs_dir = os.path.abspath(os.path.expanduser(options.eggs)) else: eggs_dir = tempfile.mkdtemp() if options.setup_source is None: if options.use_distribute: options.setup_source = distribute_source else: options.setup_source = setuptools_source if options.accept_buildout_test_releases: args.append('buildout:accept-buildout-test-releases=true') args.append('bootstrap') try: import pkg_resources import setuptools # A flag. Sometimes pkg_resources is installed alone. if not hasattr(pkg_resources, '_distribute'): raise ImportError except ImportError: ez_code = urllib2.urlopen( options.setup_source).read().replace('\r\n', '\n') ez = {} exec ez_code in ez setup_args = dict(to_dir=eggs_dir, download_delay=0) if options.download_base: setup_args['download_base'] = options.download_base if options.use_distribute: setup_args['no_fake'] = True ez['use_setuptools'](**setup_args) if 'pkg_resources' in sys.modules: reload(sys.modules['pkg_resources']) 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) cmd = [quote(sys.executable), '-c', quote('from setuptools.command.easy_install import main; main()'), '-mqNxd', quote(eggs_dir)] if not has_broken_dash_S: cmd.insert(1, '-S') find_links = options.download_base if not find_links: find_links = os.environ.get('bootstrap-testing-find-links') if find_links: cmd.extend(['-f', quote(find_links)]) if options.use_distribute: setup_requirement = 'distribute' else: setup_requirement = 'setuptools' ws = pkg_resources.working_set setup_requirement_path = ws.find( pkg_resources.Requirement.parse(setup_requirement)).location env = dict( os.environ, PYTHONPATH=setup_requirement_path) requirement = 'zc.buildout' version = options.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): 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=[setup_requirement_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) if is_jython: import subprocess exitcode = subprocess.Popen(cmd, env=env).wait() else: # Windows prefers this, apparently; otherwise we would prefer subprocess exitcode = os.spawnle(*([os.P_WAIT, sys.executable] + cmd + [env])) if exitcode != 0: sys.stdout.flush() sys.stderr.flush() print ("An error occurred when trying to install zc.buildout. " "Look above this message for any errors that " "were output by easy_install.") sys.exit(exitcode) ws.add_entry(eggs_dir) ws.require(requirement) import zc.buildout.buildout zc.buildout.buildout.main(args) if not options.eggs: # clean up temporary egg directory shutil.rmtree(eggs_dir) zope.deprecation-4.0.2/.bzrignore0000644000175000017500000000011011744110542016663 0ustar tseavertseaver.coverage *.egg-info __pycache__ .tox nosetests.xml coverage.xml _build zope.deprecation-4.0.2/src/0000775000175000017500000000000012070355010015454 5ustar tseavertseaverzope.deprecation-4.0.2/src/zope.deprecation.egg-info/0000775000175000017500000000000012070355010022417 5ustar tseavertseaverzope.deprecation-4.0.2/src/zope.deprecation.egg-info/top_level.txt0000644000175000017500000000000512070355010025142 0ustar tseavertseaverzope zope.deprecation-4.0.2/src/zope.deprecation.egg-info/SOURCES.txt0000644000175000017500000000123112070355010024276 0ustar tseavertseaver.bzrignore CHANGES.txt COPYRIGHT.txt LICENSE.txt README.txt 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 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.0.2/src/zope.deprecation.egg-info/PKG-INFO0000644000175000017500000000656012070355010023521 0ustar tseavertseaverMetadata-Version: 1.0 Name: zope.deprecation Version: 4.0.2 Summary: Zope Deprecation Infrastructure Home-page: http://pypi.python.org/pypi/zope.deprecation Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Description: ``zope.deprecation`` README =========================== This package provides a simple function called ``deprecated(names, reason)`` to mark deprecated modules, classes, functions, methods and properties. Please see http://docs.zope.org/zope.deprecation/ for the documentation. ``zope.deprecation`` Changelog ============================== 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. Platform: UNKNOWN Classifier: Intended Audience :: Developers Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.2 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Framework :: Zope3 zope.deprecation-4.0.2/src/zope.deprecation.egg-info/dependency_links.txt0000644000175000017500000000000112070355010026463 0ustar tseavertseaver zope.deprecation-4.0.2/src/zope.deprecation.egg-info/not-zip-safe0000644000175000017500000000000111757254650024666 0ustar tseavertseaver zope.deprecation-4.0.2/src/zope.deprecation.egg-info/namespace_packages.txt0000644000175000017500000000000512070355010026743 0ustar tseavertseaverzope zope.deprecation-4.0.2/src/zope.deprecation.egg-info/requires.txt0000644000175000017500000000006212070355010025013 0ustar tseavertseaversetuptools [docs] Sphinx [testing] nose coveragezope.deprecation-4.0.2/src/zope/0000775000175000017500000000000012070355010016431 5ustar tseavertseaverzope.deprecation-4.0.2/src/zope/__init__.py0000644000175000017500000000007011737604172020554 0ustar tseavertseaver__import__('pkg_resources').declare_namespace(__name__) zope.deprecation-4.0.2/src/zope/deprecation/0000775000175000017500000000000012070355010020726 5ustar tseavertseaverzope.deprecation-4.0.2/src/zope/deprecation/__init__.py0000644000175000017500000000170211737604172023054 0ustar tseavertseaver############################################################################## # # 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__ zope.deprecation-4.0.2/src/zope/deprecation/fixture.py0000644000175000017500000000003211744110542022765 0ustar tseavertseaver# used by tests abc = 1 zope.deprecation-4.0.2/src/zope/deprecation/tests.py0000644000175000017500000004077011737604172022467 0ustar tseavertseaverimport 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 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__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): cls = self._getTargetClass() return cls(module, msg) 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__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): cls = self._getTargetClass() return cls(prop, msg) 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__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__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__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): from zope.deprecation.deprecation import DeprecatedMethod return DeprecatedMethod(method, message) 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_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): from zope.deprecation.deprecation import deprecated return deprecated(spec, message) 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_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) 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): cls = self._getTargetClass() return cls(msg) def fixture(self): return 'fixture' def test___call__(self): proxy = self._makeOne('hello') result = proxy(functionfixture) self.assertEqual(result(self), None) self.assertEqual( self.warnings.w, [('hello', DeprecationWarning, 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): from zope.deprecation.deprecation import moved return moved(to_location, unsupported_in) 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_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 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(self): pass zope.deprecation-4.0.2/src/zope/deprecation/deprecation.py0000644000175000017500000001550611744110542023610 0ustar tseavertseaver############################################################################## # # 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 PY3 = sys.version_info[0] == 3 if PY3: #pragma NO COVER str_and_sequence_types = (str, list, tuple) else: #pragma NO COVER str_and_sequence_types = (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() ogetattr = object.__getattribute__ class DeprecationProxy(object): def __init__(self, module): self.__original_module = module self.__deprecated = {} def deprecate(self, names, message): """Deprecate the given names.""" if not isinstance(names, (tuple, list)): names = (names,) for name in names: self.__deprecated[name] = message 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__(): warnings.warn( name + ': ' + self.__deprecated[name], DeprecationWarning, 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): self.__original_module = module self.__msg = msg def __getattribute__(self, name): if name.startswith('_DeprecatedModule__'): return ogetattr(self, name) if name == '__class__': return types.ModuleType if __show__(): warnings.warn(self.__msg, DeprecationWarning, 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): self.message = message self.prop = prop def __get__(self, inst, klass): if __show__(): warnings.warn(self.message, DeprecationWarning, 2) return self.prop.__get__(inst, klass) class DeprecatedGetSetProperty(DeprecatedGetProperty): def __set__(self, inst, prop): if __show__(): warnings.warn(self.message, DeprecationWarning, 2) self.prop.__set__(inst, prop) class DeprecatedGetSetDeleteProperty(DeprecatedGetSetProperty): def __delete__(self, inst): if __show__(): warnings.warn(self.message, DeprecationWarning, 2) self.prop.__delete__(inst) def DeprecatedMethod(method, message): def deprecated_method(self, *args, **kw): if __show__(): warnings.warn(message, DeprecationWarning, 2) return method(self, *args, **kw) return deprecated_method def deprecated(specifier, message): """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) # 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) elif isinstance(specifier, types.ModuleType): return DeprecatedModule(specifier, message) else: prop = specifier if hasattr(prop, '__get__') and hasattr(prop, '__set__') and \ hasattr(prop, '__delete__'): return DeprecatedGetSetDeleteProperty(prop, message) elif hasattr(prop, '__get__') and hasattr(prop, '__set__'): return DeprecatedGetSetProperty(prop, message) elif hasattr(prop, '__get__'): return DeprecatedGetProperty(prop, message) class deprecate(object): """Deprecation decorator""" def __init__(self, msg): self.msg = msg def __call__(self, func): return DeprecatedMethod(func, self.msg) def moved(to_location, unsupported_in=None): 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, DeprecationWarning, 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.0.2/README.txt0000644000175000017500000000043111754767536016413 0ustar tseavertseaver``zope.deprecation`` README =========================== This package provides a simple function called ``deprecated(names, reason)`` to mark deprecated modules, classes, functions, methods and properties. Please see http://docs.zope.org/zope.deprecation/ for the documentation. zope.deprecation-4.0.2/COPYRIGHT.txt0000644000175000017500000000004011737604172017005 0ustar tseavertseaverZope Foundation and Contributorszope.deprecation-4.0.2/LICENSE.txt0000644000175000017500000000402611737604172016527 0ustar tseavertseaverZope 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.0.2/CHANGES.txt0000644000175000017500000000315212070354763016513 0ustar tseavertseaver``zope.deprecation`` Changelog ============================== 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.0.2/docs/0000775000175000017500000000000012070355010015615 5ustar tseavertseaverzope.deprecation-4.0.2/docs/api.rst0000644000175000017500000003136611744110542017135 0ustar tseavertseaver: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(): #pragma NO COVER (used only in doctests) ... return 1 ... deprecated('demo1', 'demo1 is no more.') ... ... def demo2(): #pragma NO COVER (used only in doctests) ... return 2 ... deprecated('demo2', 'demo2 is no more.') ... ... def demo3(): #pragma NO COVER (used only in doctests) ... return 3 ... deprecated('demo3', 'demo3 is no more.') ... ... def demo4(): #pragma NO COVER (used only in doctests) ... return 4 ... def deprecatedemo4(): #pragma NO COVER (used only in doctests) ... """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.message #XXX oddball case: why nested? 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.message # XXX see above 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.message # XXX see above 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.message # XXX see above 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.message # XXX see above 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 modules.iteritems(): ... pname = name.split('.') ... if pname[-1] == '__init__': ... os.mkdir(os.path.join(tmp_d, *pname[:-1])) #* highlightfail ... name = '.'.join(pname[:-1]) ... open(os.path.join(tmp_d, *pname)+'.py', 'w').write(src) #* hf ... created_modules.append(name) >>> 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.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.func_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: .. doctest:: >>> import zope.deprecation.old_package.m3 Traceback (most recent call last): ... ImportError: No module named m3 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 an attribute called ``__show__``. One can ask for its status by calling it: .. doctest:: >>> from zope.deprecation import __show__ >>> __show__() True >>> 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 warnings.catch_warnings(record=True) as log: ... del warnings.filters[:] ... foo.bar 1 >>> print log[0].message bar is no more. You can turn off the depraction warnings using .. 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.0.2/docs/make.bat0000644000175000017500000001177211744110542017236 0ustar tseavertseaver@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.0.2/docs/Makefile0000644000175000017500000001274011744110542017265 0ustar tseavertseaver# 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.0.2/docs/conf.py0000644000175000017500000001740011744110542017122 0ustar tseavertseaver# -*- 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.0.2/docs/index.rst0000644000175000017500000000034611776553233017502 0ustar tseavertseaver:mod:`zope.deprecation` Documentation ===================================== Contents: .. toctree:: :maxdepth: 2 api hacking Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` zope.deprecation-4.0.2/docs/hacking.rst0000664000175000017500000002301411776553770020004 0ustar tseavertseaverHacking on :mod:`zope.deprecation` ================================== Getting the Code ----------------- The main repository for :mod:`zope.deprecation` is in the Zope Subversion repository: http://svn.zope.org/zope.deprecation You can get a read-only Subversion checkout from there: .. code-block:: sh $ svn checkout svn://svn.zope.org/repos/main/zope.deprecation/trunk zope.deprecation The project also mirrors the trunk from the Subversion 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 Running the tests in a ``virtualenv`` ------------------------------------- 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 Finally, 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 in a ``virtualenv`` ---------------------------------------------- :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. Running the tests using :mod:`zc.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/tseaver/projects/Zope/BTK/deprecation/.' ... Generated script '.../bin/sphinx-quickstart'. Generated script '.../bin/sphinx-build'. You can now 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. Building the documentation using :mod:`zc.buildout` --------------------------------------------------- The :mod:`zope.deprecation` buildout installs the Sphinx scripts required to build the documentation, including testing its code snippets: .. code-block:: sh $ cd docs $ bin/sphinx-build -b doctest -d docs/_build/doctrees docs docs/_build/doctest ... Doctest summary =============== 140 tests 0 failures in tests 0 failures in setup code build succeeded. Testing of doctests in the sources finished, look at the results in .../docs/_build/doctest/output.txt. .../bin/sphinx-build -b html -d .../docs/_build/doctrees .../docs .../docs/_build/html ... build succeeded. Running Tests on Multiple Python Versions via :mod:`tox` -------------------------------------------------------- `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`` environment builds a ``virtualenv`` with ``python2.6``, installs :mod:`zope.deprecation`, and runs the tests via ``python setup.py test -q``. - The ``py27`` environment builds a ``virtualenv`` with ``python2.7``, installs :mod:`zope.deprecation`, and runs the tests via ``python setup.py test -q``. - The ``py32`` environment builds a ``virtualenv`` with ``python3.2``, installs :mod:`zope.deprecation` and dependencies, and runs the tests via ``python setup.py test -q``. - The ``pypy`` environment builds a ``virtualenv`` with ``pypy``, installs :mod:`zope.deprecation`, 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 :) Submitting a Bug Report ----------------------- :mod:`zope.deprecation` tracks its bugs on Launchpad: https://bugs.launchpad.net/zope.deprecation 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 you got a read-only checkout from the Subversion repository, and you have made a change you would like to share, the best route is to let Subversion help you make a patch file: .. code-block:: sh $ svn diff > zope.deprecation-cool_feature.patch You can then upload that patch file as an attachment to a Launchpad bug report. 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:~tseaver/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.