This file is indexed.

/usr/share/pyshared/z3c/autoinclude/zcml.py is in python-z3c.autoinclude 0.3.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
from zope.interface import Interface
from zope.configuration.xmlconfig import include, includeOverrides
from zope.configuration.fields import GlobalObject
from zope.dottedname.resolve import resolve
from zope.schema import BytesLine

from z3c.autoinclude import api
from z3c.autoinclude.dependency import DependencyFinder
from z3c.autoinclude.utils import distributionForPackage
from z3c.autoinclude.plugin import PluginFinder

import logging
log = logging.getLogger("z3c.autoinclude")

def includeZCMLGroup(_context, info, filename, override=False):
    includable_zcml = info[filename]
    # ^^ a key error would mean that we are trying to include a group of ZCML
    #    with a filename that wasn't ever searched for. that *should* be an error

    zcml_context = repr(_context.info)

    for dotted_name in includable_zcml:
        log.debug('including file %s from package %s at %s', filename, dotted_name, zcml_context)

    for dotted_name in includable_zcml:
        includable_package = resolve(dotted_name)
        if override:
            includeOverrides(_context, filename, includable_package)
        else:
            include(_context, filename, includable_package)


class IIncludeDependenciesDirective(Interface):
    """Auto-include any ZCML in the dependencies of this package."""
    
    package = GlobalObject(
        title=u"Package to auto-include for",
        description=u"""
        Auto-include all dependencies of this package.
        """,
        required=True,
        )

def includeDependenciesDirective(_context, package):

    if api.dependencies_disabled():
        log.warn('z3c.autoinclude.dependency is disabled but is being invoked by %s' % _context.info)
        return

    dist = distributionForPackage(package)
    info = DependencyFinder(dist).includableInfo(['configure.zcml', 'meta.zcml'])

    includeZCMLGroup(_context, info, 'meta.zcml')
    includeZCMLGroup(_context, info, 'configure.zcml')

def includeDependenciesOverridesDirective(_context, package):

    if api.dependencies_disabled():
        log.warn('z3c.autoinclude.dependency is disabled but is being invoked by %s' % _context.info)
        return

    dist = distributionForPackage(package)
    info = DependencyFinder(dist).includableInfo(['overrides.zcml'])
    includeZCMLGroup(_context, info, 'overrides.zcml', override=True)


class IIncludePluginsDirective(Interface):
    """Auto-include any ZCML in the dependencies of this package."""
    
    package = GlobalObject(
        title=u"Package to auto-include for",
        description=u"""
        Auto-include all plugins to this package.
        """,
        required=True,
        )

    file = BytesLine(
        title=u"ZCML filename to look for",
        description=u"""
        Name of a particular ZCML file to look for.
        If omitted, autoinclude will scan for standard filenames
        (e.g. meta.zcml, configure.zcml, overrides.zcml)
        """,
        required=False,
        )


def includePluginsDirective(_context, package, file=None):

    if api.plugins_disabled():
        log.warn('z3c.autoinclude.plugin is disabled but is being invoked by %s' % _context.info)
        return

    dotted_name = package.__name__

    if file is None:
        zcml_to_look_for = ['meta.zcml', 'configure.zcml']
    else:
        zcml_to_look_for = [file]
    info = PluginFinder(dotted_name).includableInfo(zcml_to_look_for)

    for filename in zcml_to_look_for:
        includeZCMLGroup(_context, info, filename)

def includePluginsOverridesDirective(_context, package, file=None):

    if api.plugins_disabled():
        log.warn('z3c.autoinclude.plugin is disabled but is being invoked by %s' % _context.info)
        return

    dotted_name = package.__name__
    if file is None:
        zcml_to_look_for = ['overrides.zcml']
    else:
        zcml_to_look_for = [file]
    info = PluginFinder(dotted_name).includableInfo(zcml_to_look_for)

    for filename in zcml_to_look_for:
        includeZCMLGroup(_context, info, filename, override=True)