<commit_before>
from Library import *
from Entity import *
from EventEntity import *
from AnalogEntity import *
from SegmentEntity import *
from NeuralEntity import *

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 = load_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):
        if self._handle:
            self._lib._close_file (self)
            self._handle = None

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

    @property
    def file_type(self):
        pass

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

    @property
    def app_name(self):
        return self._info['AppName']

    @property
    def comment(self):
        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):
        return self._info['TimeSpan']

    @property
    def time_stamp_resolution(self):
        return self.info['TimeStampResolution']

    @property
    def ctime(self):
        """The time when this file was created, i.e. the data recorded"""
        from datetime import datetime<commit_msg>File: Fix file_type property to actually return data<commit_after>
from Library import *
from Entity import *
from EventEntity import *
from AnalogEntity import *
from SegmentEntity import *
from NeuralEntity import *

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 = load_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):
        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):
        return self._info['AppName']

    @property
    def comment(self):
        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):
        return self._info['TimeSpan']

    @property
    def time_stamp_resolution(self):
        return self.info['TimeStampResolution']

    @property
    def ctime(self):
        """The time when this file was created, i.e. the data recorded"""
        from datetime import datetime
{'fraction_non_alphanumeric': 0.0903054448871182, 'fraction_numerical': 0.0008853474988933156, 'mean_word_length': 2.5085403726708075, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1311069', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1230, 'n_words': 399}