~notmyname/swift/deslogging

« back to all changes in this revision

Viewing changes to swift/__init__.py

  • Committer: Tarmac
  • Author(s): Soren Hansen
  • Date: 2011-05-27 13:32:07 UTC
  • mfrom: (300.1.4 1.4.0-versioning)
  • Revision ID: tarmac-20110527133207-1ajnpsfmfoxqk7kv
Add a __canonical_version__ attribute to the swift module. This is only the numbered part of the version string, no "-dev" or similar suffixes.

Add a couple of unit tests to make sure __version__ and __canonical_version__ are generated correctly and to ensure __canonical_version__ never accidentally has anything other than numbers and points in it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import gettext
2
2
 
3
3
 
4
 
__version__ = '1.4-dev'
 
4
class Version(object):
 
5
    def __init__(self, canonical_version, final):
 
6
        self.canonical_version = canonical_version
 
7
        self.final = final
 
8
 
 
9
    @property
 
10
    def pretty_version(self):
 
11
        if self.final:
 
12
            return self.canonical_version
 
13
        else:
 
14
            return '%s-dev' % (self.canonical_version,)
 
15
 
 
16
 
 
17
_version = Version('1.4.0', False)
 
18
__version__ = _version.pretty_version
 
19
__canonical_version__ = _version.canonical_version
 
20
 
5
21
gettext.install('swift')