This file is indexed.

/usr/share/pyshared/djapian/space.py is in python-django-djapian 2.3.1-3.

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
import os
import new

from django.db import models
from django.conf import settings
from django.utils.datastructures import SortedDict

from djapian import utils
from djapian.database import Database
from djapian.indexer import Indexer

class IndexSpace(object):
    instances = []

    def __init__(self, base_dir, name):
        self._base_dir = os.path.abspath(base_dir)
        self._indexers = SortedDict()
        self._name = name

        self.__class__.instances.append(self)

    def __unicode__(self):
        return self._name

    def __str__(self):
        from django.utils.encoding import smart_str
        return smart_str(self.__unicode__())

    def add_index(self, model, indexer=None, attach_as=None):
        if indexer is None:
            indexer = self.create_default_indexer(model)

        db = Database(
            os.path.join(
                self._base_dir,
                model._meta.app_label,
                model._meta.object_name.lower(),
                indexer.get_descriptor()
            )
        )

        indexer = indexer(db, model)

        if attach_as is not None:
            if hasattr(model, attach_as):
                raise ValueError("Attribute with name `%s` is already exist" % attach_as)
            else:
                model.add_to_class(attach_as, indexer)

        if model in self._indexers:
            self._indexers[model].append(indexer)
        else:
            self._indexers[model] = [indexer]

        return indexer

    def get_indexers(self):
        return self._indexers

    def get_indexers_for_model(self, model):
        try:
            return self._indexers[model]
        except KeyError:
            return []

    def create_default_indexer(self, model):
        tags = []
        fields = []

        for field in model._meta.fields:
            if isinstance(field, models.TextField):
                fields.append(field.attname)
            else:
                tags.append((field.name, field.attname))

        return new.classobj(
            "Default%sIndexer" % utils.model_name(model).replace('.', ''),
            (Indexer,),
            {
                "tags": tags,
                "fields": fields
            }
        )