<commit_before>'''
Created on Dec 4, 2012

@author: <a href="mailto:<EMAIL>"><NAME></a>
'''

from pyLCIO import EVENT

class Reader( object ):
    ''' Generic reader class '''

    def __init__( self, reader, fileName=None ):
        ''' Constructor '''
        self.reader = reader
        self.fileList = []
        self.fileIter = iter( self.fileList )
        self.isOpen = False
        
        if fileName and isinstance( fileName, basestring ):
            self.addFile( fileName )
        elif isinstance( fileName, list ):
            self.addFileList( fileName )
    
    def __iter__( self ):
        return self
    
    def getNumberOfEvents( self ):
        ''' Get the number of events in the stream '''
        if len(fileList) == 0:
            return 0
        if not self.isOpen:
            self.__open__( self.fileList[0] )
        return self.reader.getNumberOfEvents()
    
    def addFile( self, fileName ):
        ''' Add a file to the list of files to be read '''
        self.fileList.append( fileName )
            
    def addFiles( self, files ):
        ''' Add a list of file names to be read '''
        self.fileList.extend( files )
    
    def addFileList( self, fileListName ):<commit_msg>Fixed a bug in getNumberOfEvents (spotted by Eduard)<commit_after>'''
Created on Dec 4, 2012

@author: <a href="mailto:<EMAIL>"><NAME></a>
'''

from pyLCIO import EVENT

class Reader( object ):
    ''' Generic reader class '''

    def __init__( self, reader, fileName=None ):
        ''' Constructor '''
        self.reader = reader
        self.fileList = []
        self.fileIter = iter( self.fileList )
        self.isOpen = False
        
        if fileName and isinstance( fileName, basestring ):
            self.addFile( fileName )
        elif isinstance( fileName, list ):
            self.addFileList( fileName )
    
    def __iter__( self ):
        return self
    
    def getNumberOfEvents( self ):
        ''' Get the number of events in the stream '''
        if len(self.fileList) == 0:
            return 0
        if not self.isOpen:
            self.__open__( self.fileList[0] )
        return self.reader.getNumberOfEvents()
    
    def addFile( self, fileName ):
        ''' Add a file to the list of files to be read '''
        self.fileList.append( fileName )
            
    def addFiles( self, files ):
        ''' Add a list of file names to be read '''
        self.fileList.extend( files )
    
    def addFileList( self, fileListName ):
{'fraction_non_alphanumeric': 0.1084, 'fraction_numerical': 0.0064, 'mean_word_length': 2.0241837968561063, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3285816', 'n_tokens_mistral': 711, 'n_tokens_neox': 707, 'n_words': 229}