This file is indexed.

/usr/share/pyshared/mx/DateTime/ODMG.py is in python-egenix-mxdatetime 3.2.1-1ubuntu1.

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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
""" ODMG type classes for date/time handling

    These are built on top of the basic DateTime[Delta] types and
    include rudimentary time zone handling through an offset in
    minutes. It is the applications responsibility to set the offset
    to correct values. The offsets are then used in date calculations.

    The implementation has not yet been thoroughly tested, but
    provides a good example of the swiftness with which you can build
    new date/time classes on top of the two basic types. If you find
    any errors or would like to see new features, mail them to
    mal@lemburg.com.

"""
__version__ = '0.1alpha'
__author__ = 'Marc-Andre Lemburg, mailto:mal@lemburg.com'

import DateTime

class _EmptyClass: pass

class Date:

    offset = 0                  # from some imaginary time zone in minutes

    def __init__(self,*args):

        self.data = apply(DateTime.DateTime,args)

    def set_timezone(self,offset):

        self.offset = offset

    def __getattr__(self,what):

        return getattr(self.data,what)

    def __sub__(self,other):

        if isinstance(other,Date):
            if self.offset != other.offset:
                # Be careful about different offsets:
                d = (self.data - self.offset * DateTime.oneMinute) \
                    - (other.data - other.offset * DateTime.oneMinute)
            else:
                # Offsets are equal: no adjustment needed
                d = self.data - other.data
            o = _EmptyClass()
            o.__class__ = Interval
            o.data = d
            return o
        elif isinstance(other,Interval):
            d = self.data - other.data
            o = _EmptyClass()
            o.__class__ = Date
            o.data = d
            o.offset = self.offset # inherit the offset
            return o
        else:
            raise TypeError,"operation not supported"

    def __add__(self,other):

        if isinstance(other,Interval):
            d = self.data + other.data
            o = _EmptyClass()
            o.__class__ = Date
            o.data = d
            o.offset = self.offset # inherit the offset
            return o
        else:
            raise TypeError,"operation not supported"

    def __str__(self):
        return str(self.data)

    def __repr__(self):
        return '<Date object for "%s" at %x>' % (str(self.data),id(self))

class Timestamp(Date):

    def __repr__(self):
        return '<Timestamp object for "%s" at %x>' % (str(self.data),id(self))

class Time:

    def __init__(self,*args):

        self.data = apply(DateTime.TimeDelta,args)

    def __getattr__(self,what):

        return getattr(self.data,what)

    def __sub__(self,other):

        if isinstance(other,Time):
            d = self.data - other.data
            o = _EmptyClass()
            o.__class__ = Interval
            o.data = d
            return o
        elif isinstance(other,Interval):
            d = self.data - other.data
            o = _EmptyClass()
            o.__class__ = Time
            o.data = d
            return o
        else:
            raise TypeError,"operation not supported"

    def __add__(self,other):

        if isinstance(other,Time):
            d = self.data + other.data
            o = _EmptyClass()
            o.__class__ = Interval
            o.data = d
            return o
        elif isinstance(other,Interval):
            d = self.data + other.data
            o = _EmptyClass()
            o.__class__ = Time
            o.data = d
            return o
        else:
            raise TypeError,"operation not supported"

    def __str__(self):
        return str(self.data)

    def __repr__(self):
        return '<Time object for "%s" at %x>' % (str(self.data),id(self))

class Interval:

    def __init__(self,*args):

        self.data = apply(DateTime.DateTimeDelta,args)

    def __getattr__(self,what):

        return getattr(self.data,what)

    def __sub__(self,other):

        if isinstance(other,Interval):
            d = self.data - other.data
            o = _EmptyClass()
            o.__class__ = Interval
            o.data = d
            return o
        else:
            raise TypeError,"operation not supported"

    def __add__(self,other):

        if isinstance(other,Interval):
            d = self.data + other.data
            o = _EmptyClass()
            o.__class__ = Interval
            o.data = d
            return o
        else:
            raise TypeError,"operation not supported"

    def __mul__(self,other):

        value = float(other)
        d = value * self.data
        o = _EmptyClass()
        o.__class__ = Interval
        o.data = d
        return o
    __rmul__ = __mul__

    def __div__(self,other):

        value = float(other)
        d = self.data / value
        o = _EmptyClass()
        o.__class__ = Interval
        o.data = d
        return o

    def __str__(self):
        return str(self.data)

    def __repr__(self):
        return '<Interval object for "%s" at %x>' % (str(self.data),id(self))

if __name__ == '__main__':
    # Some test instances to play around with
    d = Date(1998,3,2)
    e = Date(1998,1,2)
    f = Date(1998,1,2)
    f.set_timezone(60)
    t = Time(12,0,0)
    u = Time(13,0,0)