This file is indexed.

/usr/share/pyshared/martian/components.py is in python-martian 0.14-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
##############################################################################
#
# Copyright (c) 2006-2007 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################

from zope.interface import implements

from martian import util
from martian.error import GrokError
from martian.interfaces import IGrokker, IComponentGrokker
from martian.martiandirective import directive, component

class GrokkerBase(object):
    implements(IGrokker)
   
    def grok(self, name, obj, **kw):
        raise NotImplementedError

    
class GlobalGrokker(GrokkerBase):
    """Grokker that groks once per module.
    """

    def grok(self, name, obj, **kw):
        raise NotImplementedError
    

class ClassGrokker(GrokkerBase):
    """Grokker that groks classes in a module.
    """
    implements(IComponentGrokker)

    def grok(self, name, class_, module_info=None, **kw):
        module = None
        if module_info is not None:
            module = module_info.getModule()

        # Populate the data dict with information from the directives:
        for d in directive.bind().get(self.__class__):
            kw[d.name] = d.get(class_, module, **kw)
        return self.execute(class_, **kw)

    def execute(self, class_, **data):
        raise NotImplementedError


class MethodGrokker(ClassGrokker):

    def grok(self, name, class_, module_info=None, **kw):
        module = None
        if module_info is not None:
            module = module_info.getModule()

        # Populate the data dict with information from class or module
        directives = directive.bind().get(self.__class__)
        for d in directives:
            kw[d.name] = d.get(class_, module, **kw)

        # Ignore methods that are present on the component baseclass.
        basemethods = set(util.public_methods_from_class(
            component.bind().get(self.__class__)))
        methods = set(util.public_methods_from_class(class_)) - basemethods
        if not methods:
            raise GrokError("%r does not define any public methods. "
                            "Please add methods to this class to enable "
                            "its registration." % class_, class_)

        results = []
        for method in methods:
            # Directives may also be applied to methods, so let's
            # check each directive and potentially override the
            # class-level value with a value from the method *locally*.
            data = kw.copy()
            for bound_dir in directives:
                d = bound_dir.directive
                class_value = data[bound_dir.name]
                data[bound_dir.name] = d.store.get(d, method,
                                                   default=class_value)
            results.append(self.execute(class_, method, **data))

        return max(results)

    def execute(self, class_, method, **data):
        raise NotImplementedError


class InstanceGrokker(GrokkerBase):
    """Grokker that groks instances in a module.
    """
    implements(IComponentGrokker)

    def grok(self, name, class_, **kw):        
        return self.execute(class_, **kw)

    def execute(self, class_, **kw):
        raise NotImplementedError