This file is indexed.

/usr/lib/python2.7/dist-packages/rdflib/Journal.py is in python-rdflib 2.4.2-3build1.

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
import logging

_logger = logging.getLogger(__name__)

from rdflib.Graph import QuotedGraph
from rdflib.events import Event, Dispatcher
from rdflib.store import TripleAddedEvent, TripleRemovedEvent, StoreCreatedEvent


class JournalWriter(object):
    """
    Writes a journal of the store events.
    """

    def __init__(self, store, stream=None, filename=None):
        if stream is None:
            assert filename, "Must specify either stream or filename"
            stream = file(filename, "ab")
        dispatcher = store.dispatcher
        dispatcher.subscribe(TripleAddedEvent, self.journal_event)
        dispatcher.subscribe(TripleRemovedEvent, self.journal_event)
        dispatcher.subscribe(StoreCreatedEvent, self.journal_event)
        self._dumps = store.node_pickler.dumps
        self._write = stream.write

    def journal_event(self, event):
        self._write(self._dumps(event))
        self._write("\n\n")


class JournalReader(object):
    """
    Reads a journal of store events into a store.
    """

    def __init__(self, store, filename):
        self.stream = file(filename, "rb")
        self.store = store
        dispatcher = Dispatcher()
        dispatcher.subscribe(TripleAddedEvent, self.add)
        dispatcher.subscribe(TripleRemovedEvent, self.remove)
        dispatcher.subscribe(StoreCreatedEvent, self.store_created)
        loads = store.node_pickler.loads
        dispatch = dispatcher.dispatch
        lines = []
        for line in self.stream:
            if line=="\n":
                try:
                    event = loads("".join(lines))
                    dispatch(event)
                    lines = []
                except Exception, e:
                    _logger.exception(e)
                    _logger.debug("lines: '%s'" % lines)
                    lines = []
            else:
                lines.append(line)

    def add(self, event):
        context = event.context
        quoted = isinstance(context, QuotedGraph)
        self.store.add(event.triple, context, quoted)

    def remove(self, event):
        self.store.remove(event.triple, event.context)
        
    def store_created(self, event):
        n = len(self.store)
        if n>0:
            _logger.warning("Store not empty for 'store created'. Contains '%s' assertions" % n)
        # TODO: clear store