def parse_config_file(config_file_path):
extension = os.path.splitext(config_file_path)[<NUM_LIT:1>]<EOL>if extension == '<STR_LIT>':<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if extension == '<STR_LIT>':<EOL><INDENT>with open(config_file_path) as config_file:<EOL><INDENT>try:<EOL><INDENT>mapping = json.load(config_file)<EOL><DEDENT>except ValueError as e:<EOL><INDENT>logger.error("<STR_LIT>", e)<EOL>raise SyntaxError('<STR_LIT>' %(config_file_path))<EOL><DEDENT><DEDENT><DEDENT>elif extension == '<STR_LIT>':<EOL><INDENT>mapping = {}<EOL>file_dict = load_module(config_file_path)<EOL>for attr_name in dir(file_dict):<EOL><INDENT>if not (attr_name.startswith('<STR_LIT:_>') or attr_name.startswith('<STR_LIT>')):<EOL><INDENT>attr = getattr(file_dict, attr_name)<EOL>if type(attr) is dict:<EOL><INDENT>mapping.update(attr)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>with open(config_file_path) as config_file:<EOL><INDENT>lines = [line.rstrip() for line in config_file if line.rstrip() != "<STR_LIT>" and not line.startswith("<STR_LIT:#>")]<EOL>mapping = parse_config_list(lines)<EOL><DEDENT><DEDENT>return mapping<EOL>
Parse a configuration file. Currently only supports .json, .py and properties separated by '='
:param config_file_path:
:return: a dict of the configuration properties