This file is indexed.

/usr/lib/python2.7/dist-packages/kopano/properties.py is in python-kopano 8.5.5-0ubuntu1.

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
"""
Part of the high-level python bindings for Kopano

Copyright 2005 - 2016 Zarafa and its licensors (see LICENSE file)
Copyright 2017 - Kopano and its licensors (see LICENSE file)
"""

import sys

from MAPI import (
    KEEP_OPEN_READWRITE, PT_UNICODE, PT_ERROR, MAPI_E_NOT_FOUND
)

from MAPI.Defs import (
    PROP_TYPE, PROP_ID
)

from MAPI.Struct import (
    SPropValue
)

from .compat import repr as _repr
from .errors import NotFoundError

if sys.hexversion >= 0x03000000:
    from . import property_ as _prop
else:
    import property_ as _prop

class Properties(object):
    """Property mixin class"""

    def prop(self, proptag, create=False, proptype=None):
        """Return :class:`property <Property>` with given property tag.

        :param proptag: MAPI property tag
        :param create: create property if it doesn't exist
        """
        return _prop.prop(self, self.mapiobj, proptag, create=create,
            proptype=proptype)

    def get_prop(self, proptag):
        """Return :class:`property <Property>` with given proptag or
        *None* if not found.

        :param proptag: MAPI property tag
        """
        try:
            return self.prop(proptag)
        except NotFoundError:
            pass

    def create_prop(self, proptag, value, proptype=None):
        """Create :class:`property <Property>` with given proptag.

        :param proptag: MAPI property tag
        :param value: property value (or a default value is used)
        """
        return _prop.create_prop(self, self.mapiobj, proptag, value, proptype)

    def props(self, namespace=None):
        """Return all :class:`properties <Property>`."""
        return _prop.props(self.mapiobj, namespace)

    # mapi objects/properties are basically key-value stores
    # so the following provides some useful dict-like behaviour

    def get(self, proptag, default=None):
        """Return :class:`property <Property>` value for given proptag or
        *None* if property does not exist.

        :param proptag: MAPI property tag
        """
        try:
            return self.prop(proptag).value
        except NotFoundError:
            return default

    def __getitem__(self, proptag):
        """Return :class:`property <Property>` value for given proptag."""
        return self.prop(proptag).value

    def __setitem__(self, proptag, value):
        """Set :class:`property <Property>` value for given proptag,
        creating the property if it doesn't exist.
        """
        self.prop(proptag, create=True).value = value

    def __delitem__(self, proptag):
        """Delete the :class:`property <Property>` with given proptag."""
        self.delete(self.prop(proptag))

    # the following is faster in case of preloaded/cached table data,
    # because it avoids the backend preloading all item properties with
    # about 20 SQL statements _per item_ (!)

    # TODO generalize for any property?
    def _get_fast(self, proptag, default=None, must_exist=False):
        # in cache
        if proptag in self._cache:
            proptype = PROP_TYPE(self._cache[proptag].proptag)
            value = self._cache[proptag].value

            if proptype == PT_ERROR and value == MAPI_E_NOT_FOUND:
                return default

            # mapi table cells are limited to 255 characters/bytes
            # TODO check other types
            if not (proptype == PT_UNICODE and len(value) >= 255):
                return value

        # fallback to (slow) lookup
        try:
            return self.prop(proptag).value
        except NotFoundError:
            if must_exist:
                raise
            else:
                return default

    def _set_fast(self, proptag, value):
        self._cache.pop(proptag, None)
        self.mapiobj.SetProps([SPropValue(proptag, value)])
        self.mapiobj.SaveChanges(KEEP_OPEN_READWRITE)

    def __repr__(self):
        return _repr(self)