r47128 - merge forward
hawkowl-TA+aISz0psMTMxyoc4vAAJOcrHinNvQL0E9HWUfgJXw@public.gmane.org Fri, 1 Apr 2016 01:23:46 -0600 (MDT)
| Newsgroups | gmane.comp.python.twisted.commits |
|---|---|
| Message-ID | <[email protected]> |
Author: hawkowl
Date: Fri Apr 1 01:23:38 2016
New Revision: 47128
Added:
branches/constantly-7351-2/twisted/topfiles/7351.removal
Modified:
branches/constantly-7351-2/docs/core/howto/constants.rst
branches/constantly-7351-2/docs/core/howto/index.rst
branches/constantly-7351-2/setup.py
branches/constantly-7351-2/setup3.py
branches/constantly-7351-2/tox.ini
branches/constantly-7351-2/twisted/internet/_sslverify.py
branches/constantly-7351-2/twisted/internet/endpoints.py
branches/constantly-7351-2/twisted/logger/_filter.py
branches/constantly-7351-2/twisted/logger/_json.py
branches/constantly-7351-2/twisted/logger/_levels.py
branches/constantly-7351-2/twisted/logger/test/test_json.py
branches/constantly-7351-2/twisted/pair/tuntap.py
branches/constantly-7351-2/twisted/positioning/base.py
branches/constantly-7351-2/twisted/positioning/nmea.py
branches/constantly-7351-2/twisted/python/__init__.py
branches/constantly-7351-2/twisted/python/test/test_constants.py
branches/constantly-7351-2/twisted/test/test_sslverify.py
Log:
merge forward
Modified: branches/constantly-7351-2/docs/core/howto/constants.rst
==============================================================================
--- branches/constantly-7351-2/docs/core/howto/constants.rst (original)
+++ branches/constantly-7351-2/docs/core/howto/constants.rst Fri Apr 1 01:23:38 2016
@@ -1,12 +1,11 @@
-
-:LastChangedDate: $LastChangedDate$
-:LastChangedRevision: $LastChangedRevision$
-:LastChangedBy: $LastChangedBy$
-
-
Symbolic Constants
==================
+.. note::
+
+ ``twisted.python.constants`` has been deprecated in Twisted, and the same code has been spun out into `Constantly <http://constantly.readthedocs.org/en/latest/>`_\.
+ The API is identical, just install it from PyPI and replace ``import twisted.python.constants`` with ``import constantly`` in your code.
+
Overview
--------
@@ -95,14 +94,14 @@
... a = NamedConstant()
... b = NamedConstant()
... c = NamedConstant()
- ...
+ ...
>>> Letters.a < Letters.b < Letters.c
True
- >>> Letters.a > Letters.b
+ >>> Letters.a > Letters.b
False
>>> sorted([Letters.b, Letters.a, Letters.c])
[<Letters=a>, <Letters=b>, <Letters=c>]
- >>>
+ >>>
A subclass of ``Names`` may define class methods to implement custom functionality.
Consider this definition of ``METHOD`` :
@@ -118,7 +117,7 @@
PUT = NamedConstant()
POST = NamedConstant()
DELETE = NamedConstant()
-
+
@classmethod
def isIdempotent(cls, method):
"""
@@ -238,7 +237,7 @@
NO_CONTENT = ValueConstant("204")
NOT_MODIFIED = ValueConstant("304")
NOT_FOUND = ValueConstant("404")
-
+
@classmethod
def hasBody(cls, status):
"""
@@ -260,7 +259,7 @@
Constants As Flags
------------------
-
+
Integers are often used as a simple set for constants.
The values for these constants are assigned as powers of two so that bits in the integer can be set to represent them.
Individual bits are often called *flags* .
@@ -384,7 +383,7 @@
from twisted.python.constants import FlagConstant, Flags
class Permission(Flags):
...
-
+
@classmethod
def format(cls, permissions):
"""
Modified: branches/constantly-7351-2/docs/core/howto/index.rst
==============================================================================
--- branches/constantly-7351-2/docs/core/howto/index.rst (original)
+++ branches/constantly-7351-2/docs/core/howto/index.rst Fri Apr 1 01:23:38 2016
@@ -200,7 +200,7 @@
- :doc:`Symbolic constants <constants>`
- enum-like constants.
+ enum-like constants. (Deprecated, spun out into `Constantly <http://constantly.readthedocs.org/en/latest/>`_)
- :doc:`Twisted RDBMS support with adbapi <rdbms>`
Modified: branches/constantly-7351-2/setup.py
==============================================================================
--- branches/constantly-7351-2/setup.py (original)
+++ branches/constantly-7351-2/setup.py Fri Apr 1 01:23:38 2016
@@ -31,17 +31,16 @@
if os.path.exists('twisted'):
sys.path.insert(0, '.')
- requirements = ["zope.interface >= 3.6.0"]
-
from twisted.python.dist import (
STATIC_PACKAGE_METADATA, getExtensions, getScripts,
setup, _EXTRAS_REQUIRE)
- setup_args = STATIC_PACKAGE_METADATA.copy()
+ args = STATIC_PACKAGE_METADATA.copy()
- setup_args.update(dict(
+ args.update(dict(
packages=setuptools.find_packages(),
- install_requires=requirements,
+ install_requires=["zope.interface >= 3.6.0",
+ "constantly >= 15.1.0"],
conditionalExtensions=getExtensions(),
scripts=getScripts(),
include_package_data=True,
@@ -49,7 +48,7 @@
extras_require=_EXTRAS_REQUIRE,
))
- setup(**setup_args)
+ setup(**args)
if __name__ == "__main__":
Modified: branches/constantly-7351-2/setup3.py
==============================================================================
--- branches/constantly-7351-2/setup3.py (original)
+++ branches/constantly-7351-2/setup3.py Fri Apr 1 01:23:38 2016
@@ -61,7 +61,8 @@
'build_scripts': PickyBuildScripts,
},
packages=find_packages(),
- install_requires=["zope.interface >= 4.0.2"],
+ install_requires=["zope.interface >= 4.0.2",
+ "constantly >= 15.1.0"],
zip_safe=False,
include_package_data=True,
scripts=getScripts(),
Modified: branches/constantly-7351-2/tox.ini
==============================================================================
--- branches/constantly-7351-2/tox.ini (original)
+++ branches/constantly-7351-2/tox.ini Fri Apr 1 01:23:38 2016
@@ -14,6 +14,9 @@
; zope.interface is love, zope.interface is life
zope.interface
+ ;also constants
+ constantly
+
; Some relatively standard dependencies that we want to have
; We cannot use extras here, because it is not supported on Py3
{tests,coverage}: pyopenssl
Modified: branches/constantly-7351-2/twisted/internet/_sslverify.py
==============================================================================
--- branches/constantly-7351-2/twisted/internet/_sslverify.py (original)
+++ branches/constantly-7351-2/twisted/internet/_sslverify.py Fri Apr 1 01:23:38 2016
@@ -206,6 +206,8 @@
from zope.interface import Interface, implementer
+from constantly import Flags, FlagConstant
+
from twisted.internet.defer import Deferred
from twisted.internet.error import VerifyError, CertificateError
from twisted.internet.interfaces import (
@@ -215,7 +217,6 @@
from twisted.python import reflect, util
from twisted.python.deprecate import _mutuallyExclusiveArguments
from twisted.python.compat import nativeString, networkString, unicode
-from twisted.python.constants import Flags, FlagConstant
from twisted.python.failure import Failure
from twisted.python.util import FancyEqMixin
Modified: branches/constantly-7351-2/twisted/internet/endpoints.py
==============================================================================
--- branches/constantly-7351-2/twisted/internet/endpoints.py (original)
+++ branches/constantly-7351-2/twisted/internet/endpoints.py Fri Apr 1 01:23:38 2016
@@ -19,6 +19,8 @@
import socket
import warnings
+from constantly import NamedConstant, Names
+
from socket import AF_INET6, AF_INET
from zope.interface import implementer, directlyProvides
@@ -37,7 +39,6 @@
from twisted.python import log
from twisted.python.compat import nativeString, unicode, _matchingString
from twisted.python.components import proxyForInterface
-from twisted.python.constants import NamedConstant, Names
from twisted.python.failure import Failure
from twisted.python.filepath import FilePath
from twisted.python.compat import iterbytes
Modified: branches/constantly-7351-2/twisted/logger/_filter.py
==============================================================================
--- branches/constantly-7351-2/twisted/logger/_filter.py (original)
+++ branches/constantly-7351-2/twisted/logger/_filter.py Fri Apr 1 01:23:38 2016
@@ -10,7 +10,8 @@
from zope.interface import Interface, implementer
-from twisted.python.constants import NamedConstant, Names
+from constantly import NamedConstant, Names
+
from ._levels import InvalidLogLevelError, LogLevel
from ._observer import ILogObserver
Modified: branches/constantly-7351-2/twisted/logger/_json.py
==============================================================================
--- branches/constantly-7351-2/twisted/logger/_json.py (original)
+++ branches/constantly-7351-2/twisted/logger/_json.py Fri Apr 1 01:23:38 2016
@@ -9,12 +9,12 @@
import types
from json import dumps, loads
from uuid import UUID
+from constantly import NamedConstant
from ._flatten import flattenEvent
from ._file import FileLogObserver
from ._levels import LogLevel
from ._logger import Logger
-from twisted.python.constants import NamedConstant
from twisted.python.compat import unicode
from twisted.python.failure import Failure
Modified: branches/constantly-7351-2/twisted/logger/_levels.py
==============================================================================
--- branches/constantly-7351-2/twisted/logger/_levels.py (original)
+++ branches/constantly-7351-2/twisted/logger/_levels.py Fri Apr 1 01:23:38 2016
@@ -6,7 +6,7 @@
Log levels.
"""
-from twisted.python.constants import NamedConstant, Names
+from constantly import NamedConstant, Names
Modified: branches/constantly-7351-2/twisted/logger/test/test_json.py
==============================================================================
--- branches/constantly-7351-2/twisted/logger/test/test_json.py (original)
+++ branches/constantly-7351-2/twisted/logger/test/test_json.py Fri Apr 1 01:23:38 2016
@@ -200,7 +200,7 @@
def test_saveLoadLevel(self):
"""
It's important that the C{log_level} key remain a
- L{twisted.python.constants.NamedConstant} object.
+ L{constantly.NamedConstant} object.
"""
inputEvent = dict(log_level=LogLevel.warn)
loadedEvent = eventFromJSON(self.savedEventJSON(inputEvent))
Modified: branches/constantly-7351-2/twisted/pair/tuntap.py
==============================================================================
--- branches/constantly-7351-2/twisted/pair/tuntap.py (original)
+++ branches/constantly-7351-2/twisted/pair/tuntap.py Fri Apr 1 01:23:38 2016
@@ -17,11 +17,12 @@
from zope.interface import Attribute, Interface, implementer
+from constantly import Flags, FlagConstant
+
from twisted.python.util import FancyEqMixin, FancyStrMixin
from twisted.python.versions import Version
from twisted.python.reflect import fullyQualifiedName
from twisted.python.deprecate import deprecated
-from twisted.python.constants import Flags, FlagConstant
from twisted.python import log
from twisted.internet import abstract, error, task, interfaces, defer
from twisted.pair import ethernet, raw
@@ -431,4 +432,3 @@
TuntapPort.loseConnection = deprecated(
Version("Twisted", 14, 0, 0),
TuntapPort.stopListening)(TuntapPort.loseConnection)
-
Modified: branches/constantly-7351-2/twisted/positioning/base.py
==============================================================================
--- branches/constantly-7351-2/twisted/positioning/base.py (original)
+++ branches/constantly-7351-2/twisted/positioning/base.py Fri Apr 1 01:23:38 2016
@@ -12,7 +12,9 @@
from functools import partial
from operator import attrgetter
from zope.interface import implementer
-from twisted.python.constants import Names, NamedConstant
+
+from constantly import Names, NamedConstant
+
from twisted.python.util import FancyEqMixin
from twisted.positioning import ipositioning
Modified: branches/constantly-7351-2/twisted/positioning/nmea.py
==============================================================================
--- branches/constantly-7351-2/twisted/positioning/nmea.py (original)
+++ branches/constantly-7351-2/twisted/positioning/nmea.py Fri Apr 1 01:23:38 2016
@@ -25,10 +25,11 @@
import datetime
from zope.interface import implementer
+from constantly import Values, ValueConstant
+
from twisted.positioning import base, ipositioning, _sentence
from twisted.positioning.base import Angles
from twisted.protocols.basic import LineReceiver
-from twisted.python.constants import Values, ValueConstant
from twisted.python.compat import reduce, izip, nativeString, iterbytes
Modified: branches/constantly-7351-2/twisted/python/__init__.py
==============================================================================
--- branches/constantly-7351-2/twisted/python/__init__.py (original)
+++ branches/constantly-7351-2/twisted/python/__init__.py Fri Apr 1 01:23:38 2016
@@ -1,13 +1,22 @@
-
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
-
"""
-
Twisted Python: Utilities and Enhancements for Python.
-
"""
-
+from __future__ import absolute_import, division
+# Deprecating twisted.python.constants.
+from .compat import unicode
+from .versions import Version
+from .deprecate import deprecatedModuleAttribute
+
+deprecatedModuleAttribute(
+ Version("Twisted", 16, 0, 0),
+ "Please use constantly from PyPI instead.",
+ "twisted.python", "constants")
+
+del Version
+del deprecatedModuleAttribute
+del unicode
Modified: branches/constantly-7351-2/twisted/python/test/test_constants.py
==============================================================================
--- branches/constantly-7351-2/twisted/python/test/test_constants.py (original)
+++ branches/constantly-7351-2/twisted/python/test/test_constants.py Fri Apr 1 01:23:38 2016
@@ -7,11 +7,15 @@
from __future__ import division, absolute_import
+import warnings
+
from twisted.trial.unittest import TestCase
-from twisted.python.constants import (
- NamedConstant, Names, ValueConstant, Values, FlagConstant, Flags
-)
+with warnings.catch_warnings():
+ warnings.simplefilter("ignore", category=DeprecationWarning)
+ from twisted.python.constants import (
+ NamedConstant, Names, ValueConstant, Values, FlagConstant, Flags
+ )
@@ -1126,3 +1130,23 @@
mozzarella = FlagConstant(1 << 1)
pesto = FlagConstant(1 << 4)
pepperoni = FlagConstant(1 << 2)
+
+
+
+class ConstantsDeprecationTests(TestCase):
+ """
+ L{twisted.python.constants} is deprecated.
+ """
+ def test_constantsDeprecation(self):
+ """
+ L{twisted.python.constants} is deprecated since Twisted 16.0.
+ """
+ from twisted.python import constants
+ constants
+
+ warningsShown = self.flushWarnings([self.test_constantsDeprecation])
+ self.assertEqual(1, len(warningsShown))
+ self.assertEqual(
+ ("twisted.python.constants was deprecated in Twisted 16.0.0: "
+ "Please use constantly from PyPI instead."),
+ warningsShown[0]['message'])
Modified: branches/constantly-7351-2/twisted/test/test_sslverify.py
==============================================================================
--- branches/constantly-7351-2/twisted/test/test_sslverify.py (original)
+++ branches/constantly-7351-2/twisted/test/test_sslverify.py Fri Apr 1 01:23:38 2016
@@ -12,6 +12,7 @@
import itertools
from zope.interface import implementer
+from constantly import NamedConstant, Names
skipSSL = None
skipSNI = None
@@ -52,7 +53,6 @@
from twisted.internet.error import ConnectionClosed
from twisted.python.compat import nativeString, _PY3
-from twisted.python.constants import NamedConstant, Names
from twisted.python.filepath import FilePath
from twisted.python.modules import getModule