This file is indexed.

/usr/share/pyshared/dap/server.py is in python-dap 2.2.6.7-2.

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
import traceback
from StringIO import StringIO

from pkg_resources import iter_entry_points

from dap.helper import constrain
from dap.lib import escape, INDENT, __dap__
from dap.exceptions import DapError


class BaseHandler(object):

    description = 'No description available'

    def __init__(self, filepath=None, environ=None):
        self.filepath = filepath
        self.environ = environ or {}

    def _parseconstraints(self, constraints=None):
        raise NotImplementedError("Subclasses must implement _parseconstraints")

    def error(self, info):
        """Error response."""

        headers = [('Content-description', 'dods_error'),
                   ('XDODS-Server', 'dods/%s' % '.'.join([str(i) for i in __dap__])),
                   ('Content-type', 'text/plain'),
                  ]

        type_, value, traceback_ = info
        f = StringIO()
        traceback.print_exception(type_, value, traceback_, file=f)
        msg = f.getvalue()

        output = ['Error {\n',
                  INDENT, 'code = %s;\n' % getattr(type_, 'code', -1),
                  INDENT, 'message = %s;\n' % escape(msg),
                  '}']

        return headers, output


# Load responses from entry points.
for ep in iter_entry_points("dap.response"):
    setattr(BaseHandler, ep.name, ep.load().build)


class SimpleHandler(BaseHandler):

    def __init__(self, dataset, environ=None):
        self.dataset = dataset
        self.environ = environ or {}

    def _parseconstraints(self, constraints=None):
        return constrain(self.dataset, constraints)