This file is indexed.

/usr/lib/python2.7/dist-packages/pycalendar/component.py is in python-pycalendar 2.0~svn13177-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
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
##
#    Copyright (c) 2007-2012 Cyrus Daboo. All rights reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
##

from pycalendar import definitions
from pycalendar import stringutils
from pycalendar.componentbase import PyCalendarComponentBase
from pycalendar.datetime import PyCalendarDateTime
from pycalendar.property import PyCalendarProperty
import os
import time
import uuid

class PyCalendarComponent(PyCalendarComponentBase):

    uid_ctr = 1

    def __init__(self, parent=None):

        super(PyCalendarComponent, self).__init__(parent)
        self.mUID = ""
        self.mSeq = 0
        self.mOriginalSeq = 0
        self.mChanged = False


    def duplicate(self, parent=None, **args):

        other = super(PyCalendarComponent, self).duplicate(parent=parent, **args)
        other.mUID = self.mUID
        other.mSeq = self.mSeq
        other.mOriginalSeq = self.mOriginalSeq

        other.mChanged = self.mChanged

        return other


    def __repr__(self):
        return "%s: UID: %s" % (self.getType(), self.getMapKey(),)


    def getMimeComponentName(self):
        raise NotImplementedError


    def getMapKey(self):
        if hasattr(self, "mMapKey"):
            return self.mMapKey
        elif self.mUID:
            return self.mUID
        else:
            self.mMapKey = str(uuid.uuid4())
            return self.mMapKey


    def getSortKey(self):
        return self.getMapKey()


    def getMasterKey(self):
        return self.mUID


    def getUID(self):
        return self.mUID


    def setUID(self, uid):
        if uid:
            self.mUID = uid
        else:
            # Get left-side of UID (first 24 chars of MD5 digest of time, pid
            # and ctr)
            lhs_txt = ""
            lhs_txt += str(time.time())
            lhs_txt += "."
            lhs_txt += str(os.getpid())
            lhs_txt += "."
            lhs_txt += str(PyCalendarComponent.uid_ctr)
            PyCalendarComponent.uid_ctr += 1
            lhs = stringutils.md5digest(lhs_txt)

            # Get right side (domain) of message-id
            rhs = None

            # Use app name
            from pycalendar.calendar import PyCalendar
            domain = PyCalendar.sDomain
            domain += str(PyCalendarComponent.uid_ctr)

            # Use first 24 chars of MD5 digest of the domain as the
            # right-side of message-id
            rhs = stringutils.md5digest(domain)

            # Generate the UID string
            new_uid = lhs
            new_uid += "@"
            new_uid += rhs

            self.mUID = new_uid

        self.removeProperties(definitions.cICalProperty_UID)

        prop = PyCalendarProperty(definitions.cICalProperty_UID, self.mUID)
        self.addProperty(prop)


    def getSeq(self):
        return self.mSeq


    def setSeq(self, seq):
        self.mSeq = seq

        self.removeProperties(definitions.cICalProperty_SEQUENCE)

        prop = PyCalendarProperty(definitions.cICalProperty_SEQUENCE, self.mSeq)
        self.addProperty(prop)


    def getOriginalSeq(self):
        return self.mOriginalSeq


    def getChanged(self):
        return self.mChanged


    def setChanged(self, changed):
        self.mChanged = changed


    def initDTSTAMP(self):
        self.removeProperties(definitions.cICalProperty_DTSTAMP)

        prop = PyCalendarProperty(definitions.cICalProperty_DTSTAMP,
                                  PyCalendarDateTime.getNowUTC())
        self.addProperty(prop)


    def updateLastModified(self):
        self.removeProperties(definitions.cICalProperty_LAST_MODIFIED)

        prop = PyCalendarProperty(definitions.cICalProperty_LAST_MODIFIED,
                                  PyCalendarDateTime.getNowUTC())
        self.addProperty(prop)


    def finalise(self):
        # Get UID
        temps = self.loadValueString(definitions.cICalProperty_UID)
        if temps is not None:
            self.mUID = temps

        # Get SEQ
        temp = self.loadValueInteger(definitions.cICalProperty_SEQUENCE)
        if temp is not None:
            self.mSeq = temp

        # Cache the original sequence when the component is read in.
        # This will be used to synchronise changes between two instances of the
        # same calendar
        self.mOriginalSeq = self.mSeq


    def canGenerateInstance(self):
        return True


    def getTimezones(self, tzids):
        # Look for all date-time properties
        for props in self.mProperties.itervalues():
            for prop in props:
                # Try to get a date-time value from the property
                dtv = prop.getDateTimeValue()
                if dtv is not None:
                    # Add timezone id if appropriate
                    if dtv.getValue().getTimezoneID():
                        tzids.add(dtv.getValue().getTimezoneID())