root/masterdriverz/snakeoil-formatters/snakeoil/version.py @ ferringb%2540gmail.com-20070211125906-1gj7u78ll14fnaut

Revision ferringb%2540gmail.com-20070211125906-1gj7u78ll14fnaut, 1.0 kB (checked in by Brian Harring <ferringb@…>, 2 years ago)

fresh reimport, dropping history from pkgcore (no point in lugging around 10+ mb of unrelated bzr history)

Line 
1# Copyright: 2006 Marien Zwart <marienz@gentoo.org>
2# License: GPL2
3
4
5"""Version information (tied to bzr)."""
6
7__version__ = '0.1'
8
9_ver = None
10
11def get_version():
12    """@returns: a string describing the snakeoil version."""
13    global _ver
14    if _ver is not None:
15        return _ver
16
17    try:
18        from snakeoil.bzr_verinfo import version_info
19    except ImportError:
20        try:
21            from bzrlib import branch, errors
22        except ImportError:
23            ver = 'unknown (not from an sdist tarball, bzr unavailable)'
24        else:
25            try:
26                # Returns a (branch, relpath) tuple, ignore relpath.
27                b = branch.Branch.open_containing(__file__)[0]
28            except errors.NotBranchError:
29                ver = 'unknown (not from an sdist tarball, not a bzr branch)'
30            else:
31                ver = '%s:%s %s' % (b.nick, b.revno(), b.last_revision())
32    else:
33        ver = '%(branch_nick)s:%(revno)s %(revision_id)s' % version_info
34
35    _ver = 'snakeoil %s\n(bzr rev %s)' % (__version__, ver)
36
37    return _ver
Note: See TracBrowser for help on using the browser.