<commit_before>'''
Created on Mar 8,2015
@author: qiuyx
'''
from string import lower
from scan.commands.command import Command
import xml.etree.ElementTree as ET 

class ConfigLog(Command):
    '''
    Config atuomatic logging.
    '''


    def __init__(self, auto=False,errHandler=None):
        '''
        @param auto: True or False for whether logging is automatic.
                     Defaults as False.
        
        Usage::
        >>>cl=ConfigLog(True)
        '''
        self.__auto=auto
        self.__errHandler=errHandler
        
    def genXML(self):
        xml=ET.Element('config_log');
        
        ET.SubElement(xml, 'automatic').text = lower(str(self.__auto))
        #return '<config_log>'+'<automatic>'+lower(str(self.__automatic))+'</automatic>'+'</config_log>'
        
        if self.__errHandler!=None:
            ET.SubElement(xml,'error_handler').text = str(self.__errHandler)
             
        return xml
    
    def __repr__(self):
        return 'ConfigLogCommand(Automatic='+lower(str(self.__auto))+')'
        
    def toCmdString(self):
        return 'ConfigLogCommand(Automatic='+lower(str(self.__auto))+')'<commit_msg>ConfigLog command: Fix repr, all lowercase params<commit_after>'''
Created on Mar 8,2015
@author: qiuyx
'''
from string import lower
from scan.commands.command import Command
import xml.etree.ElementTree as ET 

class ConfigLog(Command):
    '''
    Config automatic logging.
    '''

    def __init__(self, auto, errhandler=None):
        '''
        @param auto: True to log all write access, False to only log via Log() command.
        Usage::
        >>>cl=ConfigLog(True)
        '''
        self.__auto=auto
        self.__errHandler=errhandler
        
    def genXML(self):
        xml=ET.Element('config_log');
        
        ET.SubElement(xml, 'automatic').text = lower(str(self.__auto))
        #return '<config_log>'+'<automatic>'+lower(str(self.__automatic))+'</automatic>'+'</config_log>'
        
        if self.__errHandler:
            ET.SubElement(xml,'error_handler').text = str(self.__errHandler)
             
        return xml
    
    def __repr__(self):
        return self.toCmdString()
        
    def toCmdString(self):
        return 'ConfigLog(%s)' % str(self.__auto)
{'fraction_non_alphanumeric': 0.1297273526824978, 'fraction_numerical': 0.0043975373790677225, 'mean_word_length': 2.5, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '5801179', 'n_tokens_mistral': 680, 'n_tokens_neox': 658, 'n_words': 141}