This file is indexed.

/usr/share/pyshared/app_plugins/library.py is in python-django-app-plugins 0.1.1-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
from django.core.exceptions import ImproperlyConfigured
from django.utils.functional import curry
from django.utils.datastructures import SortedDict

libraries = {}

def _register(lib, store, prefix, options, do_error, call):
    'generic module library registration decorator passthrough'
    if call is None:
        if do_error:
            raise RuntimeError, "No callable recieved."
        return curry(_register, lib, store, prefix, options, True)
    if not callable(call):
        raise SyntaxError, "must supply callable"
    if not hasattr(call, '__module__'):
        raise SyntaxError, "callable must have __module__ defined"
    if not hasattr(call, '__name__'):
        raise SyntaxError, "callable must have __name__ defined"
    name = call.__name__
    if prefix: name = prefix + '.' + call.__name__
    if name in store:
        raise RuntimeError, "library already has a call for " + name
    if lib.app_name is None:
        lib.app_name = call.__module__
        libraries[lib.app_name] = lib
    elif lib.app_name != call.__module__:
        raise RuntimeError, ("library is for module %s, not %s." %
                             (lib.app_name, call.__module__))
    store[name] = call
    call.options = options
    return call

class Library(object):
    def __init__(self):
        self.app_name = None
        self.point_calls = SortedDict()
        self.plugin_calls = SortedDict()

    @property
    def plugin_points(self):
        return ('.'.join([self.app_name, p]) for p in self.point_calls)

    @property
    def plugins(self):
        return ('.'.join([self.app_name, p]) for p in self.plugin_calls)

    def get_plugin_point_call(self, name):
        return self.point_calls[name]

    def get_plugin_call(self, name):
        return self.plugin_calls[name]

    def plugin_point(self, call=None, **options):
        return _register(self, self.point_calls, '', options, False, call)

    def plugin(self, call=None, **options):
        if not callable(call) and cal is not None:
            point_app = call
            call = None
        else:
            point_app = ''
        return _register(self, self.plugin_calls, point_app, options,
                         False, call)

def get_library(app):
    return libraries.get(app, None)