当前位置: 首页>>代码示例>>Python>>正文


Python versions.Version类代码示例

本文整理汇总了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')
开发者ID:0004c,项目名称:VTK,代码行数:7,代码来源:test_versions.py

示例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')
开发者ID:0004c,项目名称:VTK,代码行数:7,代码来源:test_versions.py

示例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')
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:7,代码来源:test_versions.py

示例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")
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:8,代码来源:test_versions.py

示例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)
开发者ID:0004c,项目名称:VTK,代码行数:8,代码来源:test_versions.py

示例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
开发者ID:ImmobilienScout24,项目名称:treq,代码行数:8,代码来源:test_treq_integration.py

示例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
开发者ID:jonathanj,项目名称:twisted-trac-plugins,代码行数:20,代码来源:release_macro.py

示例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')
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:21,代码来源:test_versions.py

示例9: __init__

 def __init__(self, *args, **kwargs):
     self.version = Version(*args, **kwargs)
     self.app = IDroneModelApp(self.version)
开发者ID:mleinart,项目名称:droned,代码行数:3,代码来源:app.py

示例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}
#.........这里部分代码省略.........
开发者ID:mleinart,项目名称:droned,代码行数:101,代码来源:app.py


注:本文中的twisted.python.versions.Version类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。