def test_notImplementedComparisons(self): """ Comparing a L{Version} to some other object type results in C{NotImplemented}. """ va = Version("dummy", 1, 0, 0) vb = ("dummy", 1, 0, 0) # a tuple is not a Version object self.assertEqual(va.__cmp__(vb), NotImplemented)
def test_git(self): gitDir = FilePath(self.mktemp()) gitDir.makedirs() gitDir.child("HEAD").setContent(b"ref: refs/heads/master\n") heads = gitDir.child("refs").child("heads") heads.makedirs() heads.child("master").setContent(b"a96d61d94949c0dc097d6e1c3515792e99a724d5\n") version = Version("foo", 1, 0, 0) self.assertEqual(version._parseGitDir(gitDir.path), "a96d61d94949c0dc097d6e1c3515792e99a724d5")
""" resource.Resource.__init__(self) self.data = data self.type = type def render_GET(self, request): request.setHeader(b"content-type", networkString(self.type)) request.setHeader(b"content-length", b"%d" % (len(self.data), )) if request.method == b"HEAD": return b"" return self.data render_HEAD = render_GET @deprecated(Version("Twisted", 16, 0, 0)) def addSlash(request): """ Add a trailing slash to C{request}'s URI. Deprecated, do not use. """ return _addSlash(request) def _addSlash(request): """ Add a trailing slash to C{request}'s URI. @param request: The incoming request to add the ending slash to. @type request: An object conforming to L{twisted.web.iweb.IRequest} @return: A URI with a trailing slash, with query and fragment preserved.
""" Provides klein version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update klein` to change this file. from incremental import Version __version__ = Version("klein", 20, 6, 0) __all__ = ["__version__"]
""" Provides treq version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update treq` to change this file. from incremental import Version __version__ = Version('treq', 20, 9, 0) __all__ = ["__version__"]
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Twisted Protocols: A collection of internet protocol implementations. """ from incremental import Version from twisted.python.deprecate import deprecatedModuleAttribute deprecatedModuleAttribute( Version("Twisted", 17, 9, 0), "There is no replacement for this module.", "twisted.protocols", "dict", )
Emitted when L{IReactorProcess.spawnProcess} is called in a way which may result in termination of the created child process not being reported. Deprecated in Twisted 10.0. """ MESSAGE = ("spawnProcess called, but the SIGCHLD handler is not " "installed. This probably means you have not yet " "called reactor.run, or called " "reactor.run(installSignalHandler=0). You will probably " "never see this process finish, and it may become a " "zombie process.") deprecate.deprecatedModuleAttribute( Version("Twisted", 10, 0, 0), "There is no longer any potential for zombie process.", __name__, "PotentialZombieWarning", ) class ProcessDone(ConnectionDone): __doc__ = MESSAGE = "A process has ended without apparent errors" def __init__(self, status): Exception.__init__(self, "process finished with exit code 0") self.exitCode = 0 self.signal = None self.status = status
# Copyright (c) Contributors 2020 # See License for details """ Provides seashore version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update seashore` to change this file. from incremental import Version __version__ = Version('seashore', 20, 6, 0) __all__ = ["__version__"]
def test_goodSVNEntriesTenPlus(self): """ Version should be able to parse an SVN format 10 entries file. """ version = Version("dummy", 1, 0, 0) self.assertEqual(version._parseSVNEntriesTenPlus(BytesIO(VERSION_10_ENTRIES)), b"22715")
def test_localIsShort(self): """ The local version is the same as the short version. """ va = Version("dummy", 1, 0, 0, release_candidate=1, dev=3) self.assertEqual(va.local(), va.short())
def test_rcOrpreButNotBoth(self): """ Release Candidate and prerelease can't both be given. """ with self.assertRaises(ValueError): Version("whatever", 1, 0, 0, prerelease=1, release_candidate=1)
def versionToUsefulObject(version): """ Change an AST C{Version()} to a real one. """ from incremental import Version return Version(version.args[0].s, *[x.n for x in version.args[1:] if x])
""" Provides bfa version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update bfa` to change this file. from incremental import Version __version__ = Version('bfa', 18, 2, 0) __all__ = ["__version__"]
else: hostHeader = host + b":" + intToBytes(port) self.requestHeaders.addRawHeader(b"host", hostHeader) def redirect(self, url): """ Utility function that does a redirect. The request should have finish() called after this. """ self.setResponseCode(FOUND) self.setHeader(b"location", url) DummyRequest.getClientIP = deprecated( Version('Twisted', 18, 4, 0), replacement="getClientAddress", )(DummyRequest.getClientIP) class DummyRequestTests(unittest.SynchronousTestCase): """ Tests for L{DummyRequest}. """ def test_getClientIPDeprecated(self): """ L{DummyRequest.getClientIP} is deprecated in favor of L{DummyRequest.getClientAddress} """ request = DummyRequest([])
"""Provides pyfugue version information.""" # This file is auto-generated! Do not edit! # Use `python -m incremental.update pyfugue` to change this file. from incremental import Version __version__ = Version("pyfugue", 0, 1, 0) __all__ = ["__version__"]
necessary VT102 control codes with L{assembleFormattedText}. @see: L{twisted.conch.insults.text._CharacterAttributes} @author: Jp Calderone """ from incremental import Version from twisted.conch.insults import helper, insults from twisted.python import _textattributes from twisted.python.deprecate import deprecatedModuleAttribute flatten = _textattributes.flatten deprecatedModuleAttribute( Version("Twisted", 13, 1, 0), "Use twisted.conch.insults.text.assembleFormattedText instead.", "twisted.conch.insults.text", "flatten", ) _TEXT_COLORS = { "black": helper.BLACK, "red": helper.RED, "green": helper.GREEN, "yellow": helper.YELLOW, "blue": helper.BLUE, "magenta": helper.MAGENTA, "cyan": helper.CYAN, "white": helper.WHITE, }
def test_disallowBuggyComparisons(self): """ The package names of the Version objects need to be the same. """ self.assertRaises(IncomparableVersions, operator.eq, Version("dummy", 1, 0, 0), Version("dumym", 1, 0, 0))
NOT_DONE_YET = 1 __all__ = [ "supportedMethods", "Request", "Session", "Site", "version", "NOT_DONE_YET", "GzipEncoderFactory", ] # backwards compatibility deprecatedModuleAttribute( Version("Twisted", 12, 1, 0), "Please use twisted.web.http.datetimeToString instead", "twisted.web.server", "date_time_string", ) deprecatedModuleAttribute( Version("Twisted", 12, 1, 0), "Please use twisted.web.http.stringToDatetime instead", "twisted.web.server", "string_date_time", ) date_time_string = http.datetimeToString string_date_time = http.stringToDatetime # Support for other methods may be implemented on a per-resource basis. supportedMethods = (b"GET", b"HEAD", b"POST")
def testShort(self): self.assertEqual(Version('dummy', 1, 2, 3).short(), '1.2.3')
from incremental import Version from twisted.python.deprecate import deprecatedModuleAttribute from twisted.python.compat import escape from twisted.logger import Logger NOT_DONE_YET = 1 __all__ = [ 'supportedMethods', 'Request', 'Session', 'Site', 'version', 'NOT_DONE_YET', 'GzipEncoderFactory' ] # backwards compatibility deprecatedModuleAttribute( Version("Twisted", 12, 1, 0), "Please use twisted.web.http.datetimeToString instead", "twisted.web.server", "date_time_string") deprecatedModuleAttribute( Version("Twisted", 12, 1, 0), "Please use twisted.web.http.stringToDatetime instead", "twisted.web.server", "string_date_time") date_time_string = http.datetimeToString string_date_time = http.stringToDatetime # Support for other methods may be implemented on a per-resource basis. supportedMethods = (b'GET', b'HEAD', b'POST') def quote(string, *args, **kwargs): return _quote(string.decode('charmap'), *args, **kwargs).encode('charmap')
def test_getVersionStringWithDev(self): """ L{getVersionString} includes the dev release, if any. """ self.assertEqual(getVersionString(Version("whatever", 8, 0, 0, dev=1)), "whatever 8.0.0dev1")
self.addBootstrap(xmlstream.STREAM_AUTHD_EVENT, self.deferred.callback) self.addBootstrap(xmlstream.INIT_FAILED_EVENT, deferred.errback) def buildProtocol(self, addr): """ Create an instance of XmlStream. A new authenticator instance will be created and passed to the new XmlStream. Registered bootstrap event observers are installed as well. """ xs = self.protocol(self.authenticator) xs.factory = self self.installBootstraps(xs) return xs def clientConnectionFailed(self, connector, reason): self.deferred.errback(reason) @deprecated(Version("wokkel", 18, 0, 0), "unicode.encode('idna')") def prepareIDNName(name): """ Encode a unicode IDN Domain Name into its ACE equivalent. This will encode the domain labels, separated by allowed dot code points, to their ASCII Compatible Encoding (ACE) equivalent, using punycode. The result is an ASCII byte string of the encoded labels, separated by the standard full stop. """ return name.encode('idna')
def test_baseWithNEXT(self): """ The C{base} method returns just "NEXT" when NEXT is the major version. """ self.assertEqual(Version("foo", "NEXT", 0, 0).base(), "NEXT")
""" Provides Twisted version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update Twisted` to change this file. from incremental import Version __version__ = Version('Twisted', 16, 4, 1) __all__ = ["__version__"]
def test_base(self): """ The C{base} method returns a very simple representation of the version. """ self.assertEqual(Version("foo", 1, 0, 0).base(), "1.0.0")
@rtype: L{types.MethodType} """ func = cls.__dict__[name] if _PY3: return _MethodType(func, self) return _MethodType(func, self, cls) from incremental import Version from twisted.python.deprecate import deprecatedModuleAttribute from collections import OrderedDict deprecatedModuleAttribute( Version("Twisted", 15, 5, 0), "Use collections.OrderedDict instead.", "twisted.python.compat", "OrderedDict") if _PY3: from base64 import encodebytes as _b64encodebytes from base64 import decodebytes as _b64decodebytes else: from base64 import encodestring as _b64encodebytes from base64 import decodestring as _b64decodebytes def _bytesChr(i): """
def test_baseWithDev(self): """ The base version includes 'devX' for versions with dev releases. """ self.assertEqual(Version("foo", 1, 0, 0, dev=8).base(), "1.0.0dev8")
# -*- test-case-name: twisted.web.test.test_html -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """I hold HTML generation helpers. """ from html import escape from io import StringIO from twisted.python import log from twisted.python.deprecate import deprecated from incremental import Version @deprecated(Version("Twisted", 15, 3, 0), replacement="twisted.web.template") def PRE(text): "Wrap <pre> tags around some text and HTML-escape it." return "<pre>" + escape(text) + "</pre>" @deprecated(Version("Twisted", 15, 3, 0), replacement="twisted.web.template") def UL(lst): io = StringIO() io.write("<ul>\n") for el in lst: io.write("<li> %s</li>\n" % el) io.write("</ul>") return io.getvalue() @deprecated(Version("Twisted", 15, 3, 0), replacement="twisted.web.template")
def test_baseWithReleaseCandidate(self): """ The base version includes 'rcX' for versions with prereleases. """ self.assertEqual( Version("foo", 1, 0, 0, release_candidate=8).base(), "1.0.0rc8")
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Twisted Runner: Run and monitor processes. """ from incremental import Version from twisted.python.deprecate import deprecatedModuleAttribute from twisted._version import __version__ as version __version__ = version.short() deprecatedModuleAttribute(Version("Twisted", 16, 0, 0), "Use twisted.__version__ instead.", "twisted.runner", "__version__")
@return: a bound method @rtype: L{types.MethodType} """ func = cls.__dict__[name] if _PY3: return _MethodType(func, self) return _MethodType(func, self, cls) from incremental import Version from twisted.python.deprecate import deprecatedModuleAttribute from collections import OrderedDict deprecatedModuleAttribute(Version("Twisted", 15, 5, 0), "Use collections.OrderedDict instead.", "twisted.python.compat", "OrderedDict") if _PY3: from base64 import encodebytes as _b64encodebytes from base64 import decodebytes as _b64decodebytes else: from base64 import encodestring as _b64encodebytes from base64 import decodestring as _b64decodebytes def _bytesChr(i): """ Like L{chr} but always works on ASCII, returning L{bytes}. @param i: The ASCII code point to return.
def _run(package, path, newversion, patch, rc, dev, create, _date=None, _getcwd=None, _print=print): if not _getcwd: _getcwd = os.getcwd if not _date: _date = datetime.date.today() if type(package) != str: package = package.encode('utf8') if not path: path = _findPath(_getcwd(), package) else: path = FilePath(path) if newversion and patch or newversion and dev or newversion and rc: raise ValueError("Only give --newversion") if dev and patch or dev and rc: raise ValueError("Only give --dev") if create and dev or create and patch or create and rc or \ create and newversion: raise ValueError("Only give --create") if newversion: from pkg_resources import parse_version existing = _existing_version(path) st_version = parse_version(newversion)._version release = list(st_version.release) if len(release) == 1: release.append(0) if len(release) == 2: release.append(0) v = Version( package, *release, release_candidate=st_version.pre[1] if st_version.pre else None, dev=st_version.dev[1] if st_version.dev else None) elif create: v = Version(package, _date.year - _YEAR_START, _date.month, 0) existing = v elif rc and not patch: existing = _existing_version(path) if existing.release_candidate: v = Version(package, existing.major, existing.minor, existing.micro, existing.release_candidate + 1) else: v = Version(package, _date.year - _YEAR_START, _date.month, 0, 1) elif patch: if rc: rc = 1 else: rc = None existing = _existing_version(path) v = Version(package, existing.major, existing.minor, existing.micro + 1, rc) elif dev: existing = _existing_version(path) if existing.dev is None: _dev = 0 else: _dev = existing.dev + 1 v = Version(package, existing.major, existing.minor, existing.micro, existing.release_candidate, dev=_dev) else: existing = _existing_version(path) if existing.release_candidate: v = Version(package, existing.major, existing.minor, existing.micro) else: raise ValueError( "You need to issue a rc before updating the major/minor") NEXT_repr = repr(Version(package, "NEXT", 0, 0)).split("#")[0] NEXT_repr_bytes = NEXT_repr.encode('utf8') version_repr = repr(v).split("#")[0] version_repr_bytes = version_repr.encode('utf8') existing_version_repr = repr(existing).split("#")[0] existing_version_repr_bytes = existing_version_repr.encode('utf8') _print("Updating codebase to %s" % (v.public())) for x in path.walk(): if not x.isfile(): continue original_content = x.getContent() content = original_content # Replace previous release_candidate calls to the new one if existing.release_candidate: content = content.replace(existing_version_repr_bytes, version_repr_bytes) content = content.replace( (package.encode('utf8') + b" " + existing.public().encode('utf8')), (package.encode('utf8') + b" " + v.public().encode('utf8'))) # Replace NEXT Version calls with the new one content = content.replace(NEXT_repr_bytes, version_repr_bytes) content = content.replace(NEXT_repr_bytes.replace(b"'", b'"'), version_repr_bytes) # Replace <package> NEXT with <package> <public> content = content.replace(package.encode('utf8') + b" NEXT", (package.encode('utf8') + b" " + v.public().encode('utf8'))) if content != original_content: _print("Updating %s" % (x.path,)) with x.open('w') as f: f.write(content) _print("Updating %s/_version.py" % (path.path)) with path.child("_version.py").open('w') as f: f.write( (_VERSIONPY_TEMPLATE % ( package, package, version_repr)).encode('utf8'))
from twisted.python.deprecate import deprecated, deprecatedModuleAttribute if sys.version_info >= (3, 7, 0): _PY37PLUS = True else: _PY37PLUS = False if platform.python_implementation() == "PyPy": _PYPY = True else: _PYPY = False FileType = IOBase deprecatedModuleAttribute( Version("Twisted", "NEXT", 0, 0), "Obsolete alias for io.IOBase", __name__, "FileType", ) frozenset = frozenset deprecatedModuleAttribute( Version("Twisted", "NEXT", 0, 0), "Obsolete alias for frozenset builtin type", __name__, "frozenset", ) InstanceType = object deprecatedModuleAttribute(
""" Provides Twisted version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update Twisted` to change this file. from incremental import Version __version__ = Version('Twisted', 19, 2, 1) __all__ = ["__version__"]
def test_goodSVNEntries_4(self): """ Version should be able to parse an SVN format 4 entries file. """ version = Version("dummy", 1, 0, 0) self.assertEqual(version._parseSVNEntries_4(BytesIO(VERSION_4_ENTRIES)), b"18211")