<commit_before>#!/usr/bin/python

from __future__ import print_function
import os
import sys
import json

class AppConfig:

  def getRogerEnv(self, config_dir):
    with open('{0}/roger-env.json'.format(config_dir)) as roger_env:
      roger_env = json.load(roger_env)
    return roger_env

  def getConfig(self, config_dir, config_file):
    with open('{0}/{1}'.format(config_dir, config_file)) as config:
      config = json.load(config)
    return config

  def getAppData(self, config_dir, config_file, app_name):
    config = self.getConfig(config_dir, config_file)
    app_data = ''
    if app_name in config['apps']:
      app_data = config['apps'][app_name]
    return app_data
<commit_msg>Added support for yaml config files.<commit_after>#!/usr/bin/python

from __future__ import print_function
import os
import sys
import json
import yaml

class AppConfig:

  def getRogerEnv(self, config_dir):
    with open('{0}/roger-env.json'.format(config_dir)) as roger_env:
      roger_env = json.load(roger_env)
    return roger_env

  def getConfig(self, config_dir, config_file):
    config = None
    with open('{0}/{1}'.format(config_dir, config_file)) as config_file_obj:
      config = yaml.load(config_file_obj) if config_file.lower().endswith('.yml') else json.load(config_file_obj)
    return config

  def getAppData(self, config_dir, config_file, app_name):
    config = self.getConfig(config_dir, config_file)
    app_data = ''
    if app_name in config['apps']:
      app_data = config['apps'][app_name]
    return app_data

{'fraction_non_alphanumeric': 0.11176088369070825, 'fraction_numerical': 0.003898635477582846, 'mean_word_length': 4.310344827586207, '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': '3048820', 'n_tokens_mistral': 534, 'n_tokens_neox': 518, 'n_words': 121}