本文整理汇总了Python中twisted.python.versions.Version类的典型用法代码示例。如果您正苦于以下问题:Python Version类的具体用法?Python Version怎么用?Python Version使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Version类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_goodSVNEntries_4
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')
示例2: test_goodSVNEntriesTenPlus
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')
示例3: test_goodSVNEntries_9
def test_goodSVNEntries_9(self):
"""
Version should be able to parse an SVN format 9 entries file.
"""
version = Version("dummy", 1, 0, 0)
self.assertEqual(
version._parseSVNEntries_9(StringIO(VERSION_9_ENTRIES)), '22715')
示例4: test_parseBrokenSVNEntries
def test_parseBrokenSVNEntries(self):
"""
If there is a broken SVN entries file, it should return an SVN
revision of "Unknown".
"""
version = Version("dummy", 1, 0, 0)
self.assertEquals(version._parseSVNEntries(StringIO('I like puppies')),
"Unknown")
示例5: test_notImplementedComparisons
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)
示例6: todo_relative_redirect
def todo_relative_redirect(test_method):
expected_version = Version('twisted', 13, 1, 0)
if current_version < expected_version:
test_method.todo = (
"Relative Redirects are not supported in Twisted versions "
"prior to: {0}").format(expected_version.short())
return test_method
示例7: getVersion
def getVersion(self):
versions = []
pattern = 'twisted-%s-md5sums.txt'
for md5sums in self.RELEASES.globChildren(pattern % '*'):
try:
components = map(int, md5sums.basename().split('-')[1].split('.'))
except ValueError:
pass
else:
versions.append(components)
try:
version = Version('Twisted', *max(versions))
except ValueError:
self.log.error(
"Could not parse a version from files in the RELEASES directory %s" % (
self.RELEASES.path,))
raise TracError("Error loading Twisted version information")
md5sums_file = self.RELEASES.child(pattern % version.base())
return version, md5sums_file
示例8: test_goodSVNEntries
def test_goodSVNEntries(self):
"""
Version should be able to parse an SVN entries file.
"""
version = Version("dummy", 1, 0, 0)
crap = '''<?xml version="1.0" encoding="utf-8"?>
<wc-entries
xmlns="svn:">
<entry
committed-rev="18210"
name=""
committed-date="2006-09-21T04:43:09.542953Z"
url="svn+ssh://svn.twistedmatrix.com/svn/Twisted/trunk/twisted"
last-author="exarkun"
kind="dir"
uuid="bbbe8e31-12d6-0310-92fd-ac37d47ddeeb"
repos="svn+ssh://svn.twistedmatrix.com/svn/Twisted"
revision="18211"/>
</wc-entries>
'''
self.assertEquals(version._parseSVNEntries(StringIO(crap)), '18211')
示例9: __init__
def __init__(self, *args, **kwargs):
self.version = Version(*args, **kwargs)
self.app = IDroneModelApp(self.version)
示例10: AppVersion
class AppVersion(Entity):
"""Track application versions"""
implements(IDroneModelAppVersion)
description = property( lambda self: "%s %s" % \
(self.app.name, self.version_string) )
serializable = True
def __getattribute__(self, name):
"""Overrode to fulfill Interface Obligations"""
if name in ('package','major','minor','micro','prerelease','base',\
'short'):
return self.version.__getattribute__(name)
return object.__getattribute__(self, name)
def __init__(self, *args, **kwargs):
self.version = Version(*args, **kwargs)
self.app = IDroneModelApp(self.version)
@property
def version_string(self):
"""makes a nice version string that we can use for reconstruction"""
result = '.'.join([
str(self.major),
str(self.minor),
str(self.micro),
])
if self.prerelease:
result += '.%s' % str(self.prerelease)
return result
def __getstate__(self):
return {
'app' : self.package,
'version' : self.version_string, #for proper serialization
}
def __cmp__(self, other):
"""overrode for easy comparison of AppVersion to AppVersion and Version
to AppVersion.
@raise IncomparableVersions: when the package names of the versions
differ.
@param other L{twisted.python.versions.Version},
L{IDroneModelAppVersion}, or object
@return C{int} of value -1, 0, or 1
"""
try:
if IDroneModelAppVersion.providedBy(other):
return self.version.__cmp__(other.version)
except IncomparableVersions: raise
except: pass
if isinstance(other, Version):
return self.version.__cmp__(other)
return object.__cmp__(self, other)
@staticmethod
def makeAppVersion(name, version):
"""Similar to ``makeArgs``
@return L{IDroneModelAppVersion} provider
"""
args, kwargs = AppVersion.makeArgs(name, version)
return AppVersion(*args, **kwargs)
@staticmethod
def makeVersion(name, version):
"""Similar to ``makeArgs``
@return L{twisted.python.versions.Version}
"""
args, kwargs = AppVersion.makeArgs(name, version)
return Version(*args, **kwargs)
@staticmethod
def versionExists(name, version):
"""check if this L{IDroneModelAppVersion} provider exists"""
args, kwargs = AppVersion.makeArgs(name, version)
return AppVersion.exists(*args, **kwargs)
@staticmethod
def makeArgs(name, version):
"""goes through great lengths to make args for use
by a constructor for class types -
L{IDroneModelAppVersion} providers or
L{twisted.python.versions.Version}.
@raises TypeError - if version is not convertable
@param name C{str}
@param version C{str}, C{list}, C{tuple}, or
L{twisted.python.versions.Version}
@return ((name, major, minor, micro), {'prerelease': prerelease})
"""
default = [0,0,0,0] #last number denotes pre-release
if isinstance(version, Version):
if version.package == name:
return (
(name, version.major, version.minor, version.micro),
{'prerelease': version.prerelease}
#.........这里部分代码省略.........