This file is indexed.

/usr/lib/python2.7/dist-packages/pycalendar/timezone.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
##
#    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 stringutils
from pycalendar.timezonedb import PyCalendarTimezoneDatabase

class PyCalendarTimezone(object):
    """
    Wrapper around a timezone specification. There are three options:

    UTC - when mUTC is True
    TZID - when mUTC is False and tzid is a str
    UTCOFFSET - when mUTC is False and tzid is an int
    """

    sDefaultTimezone = None

    def __init__(self, utc=None, tzid=None):

        if utc is not None:
            self.mUTC = utc
            self.mTimezone = tzid
        elif tzid is not None:
            self.mUTC = tzid.lower() == 'utc'
            self.mTimezone = None if tzid.lower() == 'utc' else tzid
        else:
            self.mUTC = True
            self.mTimezone = None

            # Copy default timezone if it exists
            if PyCalendarTimezone.sDefaultTimezone is not None:
                self.mUTC = PyCalendarTimezone.sDefaultTimezone.mUTC
                self.mTimezone = PyCalendarTimezone.sDefaultTimezone.mTimezone


    def duplicate(self):
        return PyCalendarTimezone(self.mUTC, self.mTimezone)


    def equals(self, comp):
        # Always match if any one of them is 'floating'
        if self.floating() or comp.floating():
            return True
        elif self.mUTC != comp.mUTC:
            return False
        else:
            return self.mUTC or stringutils.compareStringsSafe(self.mTimezone, comp.mTimezone)


    @staticmethod
    def same(utc1, tzid1, utc2, tzid2):
        # Always match if any one of them is 'floating'
        if PyCalendarTimezone.is_float(utc1, tzid1) or PyCalendarTimezone.is_float(utc2, tzid2):
            return True
        elif utc1 != utc2:
            return False
        else:
            return utc1 or stringutils.compareStringsSafe(tzid1, tzid2)


    @staticmethod
    def is_float(utc, tzid):
        return not utc and not tzid


    def getUTC(self):
        return self.mUTC


    def setUTC(self, utc):
        self.mUTC = utc


    def getTimezoneID(self):
        return self.mTimezone


    def setTimezoneID(self, tzid):
        self.mTimezone = tzid


    def floating(self):
        return not self.mUTC and self.mTimezone is None


    def hasTZID(self):
        return not self.mUTC and self.mTimezone is not None


    def timeZoneSecondsOffset(self, dt, relative_to_utc=False):
        if self.mUTC:
            return 0
        elif self.mTimezone is None:
            return PyCalendarTimezoneDatabase.getTimezoneOffsetSeconds(PyCalendarTimezone.sDefaultTimezone.getTimezoneID(), dt, relative_to_utc)
        elif isinstance(self.mTimezone, int):
            return self.mTimezone
        else:
            # Look up timezone and resolve date using default timezones
            return PyCalendarTimezoneDatabase.getTimezoneOffsetSeconds(self.mTimezone, dt, relative_to_utc)


    def timeZoneDescriptor(self, dt):
        if self.mUTC:
            return "(UTC)"
        elif self.mTimezone is None:
            return PyCalendarTimezoneDatabase.getTimezoneDescriptor(PyCalendarTimezone.sDefaultTimezone.getTimezoneID(), dt)
        elif isinstance(self.mTimezone, int):
            sign = "-" if self.mTimezone < 0 else "+"
            hours = abs(self.mTimezone) / 3600
            minutes = divmod(abs(self.mTimezone) / 60, 60)[1]
            return "%s%02d%02d" % (sign, hours, minutes,)
        else:
            # Look up timezone and resolve date using default timezones
            return PyCalendarTimezoneDatabase.getTimezoneDescriptor(self.mTimezone, dt)

PyCalendarTimezone.sDefaultTimezone = PyCalendarTimezone()