This file is indexed.

/usr/share/pyshared/couchdbkit/schema/util.py is in python-couchdbkit 0.6.5-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
from couchdbkit.exceptions import DocTypeError


def schema_map(schema, dynamic_properties):
    if hasattr(schema, "wrap") and hasattr(schema, '_doc_type'):
        schema = {schema._doc_type: schema}
    elif isinstance(schema, list):
        schema = dict((s._doc_type, s) for s in schema)

    if dynamic_properties is not None:
        for name, cls in schema.items():
            if cls._allow_dynamic_properties != dynamic_properties:
                schema[name] = type(cls.__name__, (cls,), {
                    '_allow_dynamic_properties': dynamic_properties,
                })
    return schema


def doctype_attr_of(classes):
    doc_type_attrs = set(cls._doc_type_attr for cls in classes)
    assert len(doc_type_attrs) == 1, "inconsistent doctype attr"
    return doc_type_attrs.pop()


def get_multi_wrapper(classes):
    doctype_attr = doctype_attr_of(classes.values())

    def wrap(doc):
        doc_type = doc.get(doctype_attr)
        try:
            cls = classes[doc_type]
        except KeyError:
            raise DocTypeError(
                "the document being wrapped has doc type {0!r}. "
                "To wrap it anyway, you must explicitly pass in "
                "classes={{{0!r}: <document class>}} to your view. "
                "This behavior is new starting in 0.6.2.".format(doc_type)
            )
        return cls.wrap(doc)

    return wrap


def schema_wrapper(schema, dynamic_properties=None):
    mapping = schema_map(schema, dynamic_properties)
    return get_multi_wrapper(mapping)


def maybe_schema_wrapper(wrapper, schema, params):
    dynamic_properties = params.pop('dynamic_properties', None)
    return wrapper or schema_wrapper(schema, dynamic_properties)