<commit_before>package h2o.common.util.debug;

import h2o.common.Tools;
import h2o.common.util.collections.CollectionUtil;
import org.apache.commons.configuration.PropertiesConfiguration;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Mode {
	
	public static final String PROD     = "PROD";
	public static final String TEST     = "TEST";
    public static final String DEV      = "DEV";
	
	private static final String mode;
	
	public static final boolean prodMode;
	public static final boolean testMode;
    public static final boolean devMode;

    public static final boolean debugMode;
	
	private static final Set<String> userModeSet = new HashSet<String>();
	
	static {
		
		boolean p = true;
		boolean t = false;
        boolean d = false;

        boolean debug;

		String m;
		
		try {

			PropertiesConfiguration config = new PropertiesConfiguration("mode.properties");
			
			m      = config.getString("mode", PROD).trim().toUpperCase();
            debug  = config.getBoolean("debug" , false );
			
			if( TEST.equals(m) ) {				
				t = true;				
			} else if( DEV.equals(m) ) {
				d = true;				
			} else {				
				p = true;
				m = PROD;
				
				Tools.log.info("default mode !!!");
			}
			
			
			
			String userModes = config.getString("userMode","").trim().toUpperCase();
			
			if( !"".equals(userModes) ) {

                List<String> ums =  CollectionUtil.string2List( false , userModes, new String[] {":",",",";"," ", "\t"} , null );
			    userModeSet.addAll( ums );

			}
			
			
			
		} catch (Throwable e) {	
			
			System.err.println(e.getClass().getName() + ":" + e.getMessage());
			
			p = true;
			d = false;
			t = false;

            debug = false;
			
			m = PROD;
		}
		
		prodMode    = p;
		devMode     = d;
		testMode    = t;

		debugMode   = debug;

		mode = m;
		
		Tools.log.info("Mode : {}"       , mode );
        Tools.log.info("Debug Mode : {}" , debugMode );
		Tools.log.info("User Mode : {}"  , userModeSet );
	}
	
	private Mode() {}
	
	
	public static boolean isMode( String m ) {
<commit_msg>没有配置文件异常<commit_after>package h2o.common.util.debug;

import h2o.common.Tools;
import h2o.common.exception.ExceptionUtil;
import h2o.common.util.collections.CollectionUtil;
import org.apache.commons.configuration.PropertiesConfiguration;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Mode {
	
	public static final String PROD     = "PROD";
	public static final String TEST     = "TEST";
    public static final String DEV      = "DEV";
	
	private static final String mode;
	
	public static final boolean prodMode;
	public static final boolean testMode;
    public static final boolean devMode;

    public static final boolean debugMode;
	
	private static final Set<String> userModeSet = new HashSet<String>();
	
	static {
		
		boolean p = false;
		boolean t = false;
        boolean d = false;

        boolean debug = false;

		String m;
		
		try {

			PropertiesConfiguration config = new PropertiesConfiguration("mode.properties");
			
			m = config.getString("mode", PROD ).trim().toUpperCase();
			try {
                debug  = config.getBoolean("debug" , false );
            } catch ( Exception e ) {

            }

			
			if( TEST.equals(m) ) {				
				t = true;				
			} else if( DEV.equals(m) ) {
				d = true;				
			} else {				
				p = true;
				m = PROD;
				
				Tools.log.info("default mode !!!");
			}
			
			
			
			String userModes = config.getString("userMode","").trim().toUpperCase();
			
			if( !"".equals(userModes) ) {

                List<String> ums =  CollectionUtil.string2List( false , userModes, new String[] {":",",",";"," ", "\t"} , null );
			    userModeSet.addAll( ums );

			}
			
			
			
		} catch (Throwable e) {

		    e.fillInStackTrace();
		    Tools.log.error( e );

		    throw ExceptionUtil.toRuntimeException(e);

		}
		
		prodMode    = p;
		devMode     = d;
		testMode    = t;

		debugMode   = debug;

		mode = m;
		
		Tools.log.info("Mode : {}"       , mode );
        Tools.log.info("Debug Mode : {}" , debugMode );
		Tools.log.info("User Mode : {}"  , userModeSet );
	}
	
	private Mode() {}
	
	
	public static boolean isMode( String m ) {

{'fraction_non_alphanumeric': 0.12936150011868028, 'fraction_numerical': 0.002136244956088298, 'mean_word_length': 2.4093851132686086, 'pattern_counts': {'":': 3, '<': 9, '<?xml version=': 0, '>': 9, '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': '824250', 'n_tokens_mistral': 1587, 'n_tokens_neox': 1288, 'n_words': 331}