def filter_data(self, data, values=None, args=None):
        """Return entries containing specified patterns (single log)"""
        if args:
            if not args.pattern:
                return data
        if not values: values = args.pattern
        newdata = {}
        if 'parser' in data.keys():
            newdata['parser'] = data['parser']
            newdata['source_path'] = data['source_path']
            newdata['source_file'] = data['source_file']
            newdata['source_file_mtime'] = data['source_file_mtime']
            newdata['source_file_year'] = data['source_file_year']
        newdata['entries'] = []

        repatterns = {}
        for pat in values:
            repatterns[pat] = re.compile(r".*({}).*".format(pat))

        for entry in data['entries']:
            for repat in repatterns:
                if re.match(repatterns[repat], entry['raw_text']):
                    newdata['entries'].append(entry)
                    break

        return newdata
def filter_data ( self , data , values = None , args = None ) : if args : if not args . pattern : return data if not values : values = args . pattern newdata = { } if 'parser' in data . keys ( ) : newdata [ 'parser' ] = data [ 'parser' ] newdata [ 'source_path' ] = data [ 'source_path' ] newdata [ 'source_file' ] = data [ 'source_file' ] newdata [ 'source_file_mtime' ] = data [ 'source_file_mtime' ] newdata [ 'source_file_year' ] = data [ 'source_file_year' ] newdata [ 'entries' ] = [ ] repatterns = { } for pat in values : repatterns [ pat ] = re . compile ( r".*({}).*" . format ( pat ) ) for entry in data [ 'entries' ] : for repat in repatterns : if re . match ( repatterns [ repat ] , entry [ 'raw_text' ] ) : newdata [ 'entries' ] . append ( entry ) break return newdata
Return entries containing specified patterns (single log)