This file is indexed.

/usr/share/pyshared/application/version.py is in python-application 1.2.8-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# Copyright (C) 2009 Dan Pascu. See LICENSE for details.
#

"""Manage the version numbers for applications, modules and packages"""

__all__ = ['Version']


class Version(str):
    """A major.minor.micro[extraversion] version string that is comparable"""

    def __new__(cls, major, minor, micro, extraversion=None):
        if major == minor == micro == extraversion == None:
            instance = str.__new__(cls, "undefined")
            instance._version_info = (None, None, None, None, None)
            return instance
        try:
            major, minor, micro = int(major), int(minor), int(micro)
        except:
            raise TypeError("major, minor and micro must be integer numbers")
        if extraversion is None:
            instance = str.__new__(cls, "%d.%d.%d" % (major, minor, micro))
            weight = 0
        elif isinstance(extraversion, (int, long)):
            instance = str.__new__(cls, "%d.%d.%d-%d" % (major, minor, micro, extraversion))
            weight = 0
        elif isinstance(extraversion, basestring):
            import re
            instance = str.__new__(cls, "%d.%d.%d%s" % (major, minor, micro, extraversion))
            match = re.match(r'^[-.]?(?P<name>(pre|rc|alpha|beta|))(?P<number>\d+)$', extraversion)
            if match:
                weight_map = {'alpha': -40, 'beta': -30, 'pre': -20, 'rc': -10, '': 0}
                weight = weight_map[match.group('name')]
                extraversion = int(match.group('number'))
            else:
                weight = 0
                extraversion = extraversion or None
        else:
            raise TypeError("extraversion must be a string, integer, long or None")
        instance._version_info = (major, minor, micro, weight, extraversion)
        return instance

    @classmethod
    def parse(self, value):
        if isinstance(value, Version):
            return value
        elif not isinstance(value, basestring):
            raise TypeError("value should be a string")
        if value == 'undefined':
            return Version(None, None, None)
        import re
        match = re.match(r'^(?P<major>\d+)(\.(?P<minor>\d+))?(\.(?P<micro>\d+))?(?P<extraversion>.*)$', value)
        if not match:
            raise ValueError("not a recognized version string")
        return Version(**match.groupdict(0))

    @property
    def major(self):
        return self._version_info[0]

    @property
    def minor(self):
        return self._version_info[1]

    @property
    def micro(self):
        return self._version_info[2]

    @property
    def extraversion(self):
        return self._version_info[4]

    def __repr__(self):
        major, minor, micro, weight, extraversion = self._version_info
        if weight is not None and weight < 0:
            weight_map = {-10: 'rc', -20: 'pre', -30: 'beta', -40: 'alpha'}
            extraversion = "%s%d" % (weight_map[weight], extraversion)
        return "%s(%r, %r, %r, %r)" % (self.__class__.__name__, major, minor, micro, extraversion)

    def __setattr__(self, name, value):
        if name == '_version_info' and hasattr(self, name):
            raise AttributeError("'%s' object attribute '%s' is read-only" % (self.__class__.__name__, name))
        str.__setattr__(self, name, value)

    def __delattr__(self, name):
        if name == '_version_info':
            raise AttributeError("'%s' object attribute '%s' is read-only" % (self.__class__.__name__, name))
        str.__delattr__(self, name)

    def __cmp__(self, other):
        if isinstance(other, self.__class__):
            return cmp(self._version_info, other._version_info)
        elif isinstance(other, basestring):
            return cmp(str(self), other)
        else:
            return NotImplemented

    def __le__(self, other):
        return self.__cmp__(other) <= 0

    def __lt__(self, other):
        return self.__cmp__(other) < 0

    def __ge__(self, other):
        return self.__cmp__(other) >= 0

    def __gt__(self, other):
        return self.__cmp__(other) > 0

    def __eq__(self, other):
        return self.__cmp__(other) == 0

    def __ne__(self, other):
        return self.__cmp__(other) != 0