<commit_before>#!/usr/bin/python

from datetime import datetime, timedelta, MINYEAR, MAXYEAR
import argparse, re

from mtools.util.logline import LogLine
from mtools.util.cmdlinetool import LogFileTool

class MLogMergeTool(LogFileTool):
    """ Merges several MongoDB log files by their date and time. 
    """

    def __init__(self):
        LogFileTool.__init__(self, multiple_logfiles=True, stdin_allowed=False)

        self.argparser.add_argument('--labels', action='store', nargs='*', default=['enum'], help='labels to distinguish original files. Choose from none, enum, alpha, filename, or provide list.')
        self.argparser.add_argument('--pos', action='store', default=0, help="position of label (default=0, front of line, other options are 'eol' or the position as int.")
        self.argparser.add_argument('--timezone', action='store', nargs='*', default=[], type=int, metavar="N", help="timezone adjustments: add N hours to corresponding log file")


    def run(self):
        LogFileTool.run(self)

        logfiles = self.args['logfile']

        # handle labels parameter
        if len(self.args['labels']) == 1:
            label = self.args['labels'][0]
            if label == 'enum':
                labels = ['{%i}'%(i+1) for i in range(len(logfiles))]
            elif label == 'alpha':
                labels = ['{%s}'%chr(97+i) for i in range(len(logfiles))]
            elif label == 'none':
                labels = [None for _ in logfiles]
            elif label == 'filename':
                labels = ['{%s}'%fn.name for fn in logfiles]
        elif len(args['labels']) == len(logfiles):
            labels = self.args['labels']
        else:
            raise SystemExit('Error: Number of labels not the same as number of files.')

        # handle timezone parameter
        if len(self.args['timezone']) == 1:
            self.args['timezone'] = self.args['timezone'] * len(logfiles)

        elif len(self.args['timezone']) == len(logfiles):
            pass

        elif len(self.args['timezone']) == 0:
            self.args['timezone'] = [0] * len(logfiles)<commit_msg>added fix to a bug with mlogmerge and multiple labels.<commit_after>#!/usr/bin/python

from datetime import datetime, timedelta, MINYEAR, MAXYEAR
import argparse, re

from mtools.util.logline import LogLine
from mtools.util.cmdlinetool import LogFileTool

class MLogMergeTool(LogFileTool):
    """ Merges several MongoDB log files by their date and time. 
    """

    def __init__(self):
        LogFileTool.__init__(self, multiple_logfiles=True, stdin_allowed=False)

        self.argparser.add_argument('--labels', action='store', nargs='*', default=['enum'], help='labels to distinguish original files. Choose from none, enum, alpha, filename, or provide list.')
        self.argparser.add_argument('--pos', action='store', default=0, help="position of label (default=0, front of line, other options are 'eol' or the position as int.")
        self.argparser.add_argument('--timezone', action='store', nargs='*', default=[], type=int, metavar="N", help="timezone adjustments: add N hours to corresponding log file")


    def run(self):
        LogFileTool.run(self)

        logfiles = self.args['logfile']

        # handle labels parameter
        if len(self.args['labels']) == 1:
            label = self.args['labels'][0]
            if label == 'enum':
                labels = ['{%i}'%(i+1) for i in range(len(logfiles))]
            elif label == 'alpha':
                labels = ['{%s}'%chr(97+i) for i in range(len(logfiles))]
            elif label == 'none':
                labels = [None for _ in logfiles]
            elif label == 'filename':
                labels = ['{%s}'%fn.name for fn in logfiles]
        elif len(self.args['labels']) == len(logfiles):
            labels = self.args['labels']
        else:
            raise SystemExit('Error: Number of labels not the same as number of files.')

        # handle timezone parameter
        if len(self.args['timezone']) == 1:
            self.args['timezone'] = self.args['timezone'] * len(logfiles)

        elif len(self.args['timezone']) == len(logfiles):
            pass

        elif len(self.args['timezone']) == 0:
            self.args['timezone'] = [0] * len(logfiles)
{'fraction_non_alphanumeric': 0.14279026217228463, 'fraction_numerical': 0.0046816479400749065, 'mean_word_length': 2.78141592920354, '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': '3803614', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1220, 'n_words': 354}