<commit_before># Base spike data.
#
# Copyright (C) 2010-2011 <NAME>
# 
# See LICENSE.TXT that came with this file.

from SpikeRecord.Plexon.PlexClient import PlexClient
from SpikeRecord.Plexon.PlexFile import PlexFile
from SpikeRecord.Plexon.PlexUtil import PlexUtil

class PlexSpikeData(object):
    # Base class handling spike records online or offline from Plexon.
    def __init__(self, file=None):
        self.read_from_server = True
        self.read_from_file = False
        self.file_has_read = False
        
        if file is None:
            self.pc = PlexClient()
            self.pc.InitClient()
        else:
            self.read_from_server = False
            self.read_from_file = True
            self.pf = PlexFile(file)
            
        self.pu = PlexUtil()
        
        self.renew_data()

    def __del__(self):
        self.pc.CloseClient()
        
    def renew_data(self):
        pass
    
    def get_data(self):
        pass
    
    def _update_data(self):
        if self.read_from_server:
            self.data = self.pc.GetTimeStampArrays()
            self.online = True
        elif self.read_from_file and not self.file_has_read:
            self.data = self.pf.GetTimeStampArrays()
            self.online = False
            self.file_has_read = True
        elif self.file_has_read:
            self.data = self.pf.GetNullTimeStamp()<commit_msg>fixbug when plexclient object is deleted<commit_after># Base spike data.
#
# Copyright (C) 2010-2011 <NAME>
# 
# See LICENSE.TXT that came with this file.

from SpikeRecord.Plexon.PlexClient import PlexClient
from SpikeRecord.Plexon.PlexFile import PlexFile
from SpikeRecord.Plexon.PlexUtil import PlexUtil

class PlexSpikeData(object):
    # Base class handling spike records online or offline from Plexon.
    def __init__(self, file=None):
        self.read_from_server = True
        self.read_from_file = False
        self.file_has_read = False
        
        self.pc = None
        self.pf = None
        
        if file is None:
            self.pc = PlexClient()
            self.pc.InitClient()
        else:
            self.read_from_server = False
            self.read_from_file = True
            self.pf = PlexFile(file)
        self.pu = PlexUtil()
        self.renew_data()

    def __del__(self):
        if self.pc is not None:
            self.pc.CloseClient()
        
    def renew_data(self):
        pass
    
    def get_data(self):
        pass
    
    def _update_data(self):
        if self.read_from_server:
            self.data = self.pc.GetTimeStampArrays()
            self.online = True
        elif self.read_from_file and not self.file_has_read:
            self.data = self.pf.GetTimeStampArrays()
            self.online = False
            self.file_has_read = True
        elif self.file_has_read:
            self.data = self.pf.GetNullTimeStamp()
{'fraction_non_alphanumeric': 0.0782006920415225, 'fraction_numerical': 0.005536332179930796, 'mean_word_length': 1.9712230215827338, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4109903', 'n_tokens_mistral': 911, 'n_tokens_neox': 887, 'n_words': 207}