<commit_before>import os
import platform
import json
import os.path

class AutoConfig:
    def __init__(self):

        self._param = {"auto_config":{}}

        system = platform.system() # Windows, Linux, Darwin
        if "Darwin" in system:
            system = "MacOS_X"
        self._param["auto_config"]["system"] = system

        pathList =[]

        if "Windows" in system:
            pathList = ( os.environ['PATH'].split(';') )
        else:
            pathList = os.environ['PATH'].split(':')

        print pathList
        script_dir_path = os.path.abspath(os.path.dirname(__file__))
        config_path = os.path.join(script_dir_path,"autoconf.json")
        config_file = open(config_path,'r')
        config = json.load(config_file)

        #search dispatcher

        self._param["auto_config"]["dispatcher"] = {}
        for dispatcher_name in config["dispatcher"].keys():
            if dispatcher_name == "localbatch":
                self._param["auto_config"]["dispatcher"][dispatcher_name] = config["dispatcher"][dispatcher_name]
                continue
#            print "test"
#            print  config[dispatcher_name]["submitter"][system].replace('\\\\','\\')
            submit_path =  config["dispatcher"][dispatcher_name]["submitter"][system].replace('\\\\','\\')
            if os.path.exists(submit_path):
                self._param["auto_config"]["dispatcher"][dispatcher_name] = {}
                for param_key in config["dispatcher"][dispatcher_name].keys():
                    self._param["auto_config"]["dispatcher"][dispatcher_name][param_key] = config["dispatcher"][dispatcher_name][param_key][system].replace('\\\\','\\')


                print "path"

        print self._param["auto_config"]["dispatcher"]
        # scan dispatcher typical point
        # scan dispatcher $PATH

        #scan registry  x too many times, too slow

        # search maya_executable

    def getparam(self):
        return self._param
<commit_msg>Refactor<commit_after>import os
import platform
import json
import os.path


class AutoConfig:
    def __init__(self):

        self._param = {"auto_config": {}}

        system = platform.system()  # Windows, Linux, Darwin
        if "Darwin" in system:
            system = "MacOS_X"
        self._param["auto_config"]["system"] = system

        pathList =[]

        if "Windows" in system:
            pathList = ( os.environ['PATH'].split(';') )
        else:
            pathList = os.environ['PATH'].split(':')

        # print pathList
        script_dir_path = os.path.abspath(os.path.dirname(__file__))
        config_path = os.path.join(script_dir_path,"autoconf.json")
        config_file = open(config_path,'r')
        config = json.load(config_file)

        # search dispatcher

        self._param["auto_config"]["dispatcher"] = {}
        for dispatcher_name in config["dispatcher"].keys():
            if dispatcher_name == "localbatch":
                self._param["auto_config"]["dispatcher"][dispatcher_name] = config["dispatcher"][dispatcher_name]
                continue
#            print "test"
#            print  config[dispatcher_name]["submitter"][system].replace('\\\\','\\')
            submit_path =  config["dispatcher"][dispatcher_name]["submitter"][system].replace('\\\\', '\\')
            if os.path.exists(submit_path):
                self._param["auto_config"]["dispatcher"][dispatcher_name] = {}
                for param_key in config["dispatcher"][dispatcher_name].keys():
                    self._param["auto_config"]["dispatcher"][dispatcher_name][param_key] = config["dispatcher"][dispatcher_name][param_key][system].replace('\\\\', '\\')

                # print "path"

        # print self._param["auto_config"]["dispatcher"]
        # scan dispatcher typical point
        # scan dispatcher $PATH

        # scan registry  x too many times, too slow

        # search maya_executable

    def getparam(self):
        return self._param
{'fraction_non_alphanumeric': 0.1447633434038268, 'fraction_numerical': 0.0, 'mean_word_length': 2.5128205128205128, 'pattern_counts': {'":': 4, '<': 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': '6682674', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1125, 'n_words': 200}