This file is indexed.

/usr/lib/python2.7/dist-packages/neuroshare/File.py is in python-neuroshare 0.9.2-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
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
from Library import Library
from Entity import EntityType
from EventEntity import EventEntity
from AnalogEntity import AnalogEntity
from SegmentEntity import SegmentEntity
from NeuralEntity import NeuralEntity


class EntityProxy(object):
    def __init__(self, nsfile):
        self._nsfile = nsfile

    def __getitem__(self, key):
        return self._nsfile.get_entity(key)

    def __iter__(self):
        for x in xrange(0, self._nsfile.entity_count):
            yield self[x]

    def __len__(self):
        return self._nsfile.entity_count


class File(object):
    """Object that represents a datafile that can be open via neuroshare at
    the location given by ``filename``. The file will be opened upon object
    construction.

    Individual entities can be opened via the :func:`get_entity` function or
    the :func:`entities` property. NB: The first entity index is **0**
    """

    def __init__(self, filename, library=None):
        self._handle = None
        self._filename = filename
        if not library:
            library = Library.for_file(filename)

        self._lib = library
        (handle, info) = self._lib._open_file(filename)
        self._handle = handle
        self._info = info
        self._eproxy = EntityProxy(self)

    def __del__(self):
        self.close()

    def close(self):
        """Close the file."""
        if self._handle:
            self._lib._close_file(self)
            self._handle = None

    @property
    def library(self):
        return self._lib

    @property
    def file_type(self):
        """Text description of the file type"""
        return self._info['FileType']

    @property
    def metadata_raw(self):
        return self._info

    @property
    def app_name(self):
        """The name of the application that created the file"""
        return self._info['AppName']

    @property
    def comment(self):
        """Additional comments"""
        return self._info['FileComment']

    @property
    def entity_count(self):
        """The number of entities in this file"""
        return self._info['EntityCount']

    @property
    def time_span(self):
        """Timespan of the data in the file [in seconds]"""
        return self._info['TimeSpan']

    @property
    def time_stamp_resolution(self):
        """Minimum resolution of timestamps [in seconds]"""
        return self._info['TimeStampResolution']

    @property
    def ctime(self):
        """The time when this file was created, i.e. the data recorded.
        Returns a :py:class:`datetime.datetime` object.
        """
        from datetime import datetime

        year = self._info['Time_Year']
        month = self._info['Time_Month']
        day = self._info['Time_Day']
        hour = self._info['Time_Hour']
        minute = self._info['Time_Min']
        sec = self._info['Time_Sec']
        millisec = self._info['Time_MilliSec']

        msec = millisec * 1000
        ct = datetime(year, month, day, hour, minute, sec, msec)
        return ct

    def get_entity(self, entity_id):
        """Open the entity at the given index."""
        info = self._lib._get_entity_info(self, entity_id)
        entity_type = info['EntityType']

        if entity_type == EntityType.Event:
            entity = EventEntity(self, entity_id, info)
        elif entity_type == EntityType.Analog:
            entity = AnalogEntity(self, entity_id, info)
        elif entity_type == EntityType.Segment:
            entity = SegmentEntity(self, entity_id, info)
        elif entity_type == EntityType.Neural:
            entity = NeuralEntity(self, entity_id, info)
        else:
            return None  # should not happen, throw exception?

        return entity

    def list_entities(self, start=0, end=-1):
        """List all entities. The range can be limited
        via the ``start`` and ``end`` parameters."""
        if end == -1:
            end = self.entity_count

        for x in xrange(start, end):
            yield self.get_entity(x)

    @property
    def entities(self):
        """Property that returns a proxy object to allow the opening of
        entities in a via indexing, ie::

            entity = datafile.entities[10] #retrieve the entity with at 10
        """
        return self._eproxy

    @property
    def _get_handle(self):
        return self._handle

    @property
    def handle(self):
        return self._handle

    def __repr__(self):
        return 'neuroshare.File(%r)' % self._filename