<commit_before>#! /usr/bin/env python

import sys, os
moddir = os.path.join( os.path.dirname( __file__ ), '..' )
sys.path = [moddir] + sys.path

from dynconfig.read import *
import json
import yaml

from argparse import ArgumentParser

parser = ArgumentParser(description="Process a set of dynamic config files.")

parser.add_argument("infile",
                    action="store",
                    help="Config files to process." )

parser.add_argument("-f", "--format",
                    action="store",
                    default="yaml",
                    help="File format." )

parser.add_argument("-o", "--output",
                    action="store",
                    default="-",
                    help="Output file",)


args = parser.parse_args()

outfile = args.output



with open(args.infile, 'r') as f:
  text = f.read()

loader = yaml.load
dumper = yaml.dump

if args.format.lower() == 'json':
  loader = yaml.loads
  dumper = yaml.dumps


config = readConfig( text, parser=loader )

text = dumper( config )

if outfile == '-':
  print text
else:
  with open(outfile, 'w') as f:<commit_msg>BUGFIX: json format was broken<commit_after>#! /usr/bin/env python

import sys, os
moddir = os.path.join( os.path.dirname( __file__ ), '..' )
sys.path = [moddir] + sys.path

from dynconfig.read import *
import json
import yaml

from argparse import ArgumentParser

parser = ArgumentParser(description="Process a set of dynamic config files.")

parser.add_argument("infile",
                    action="store",
                    help="Config files to process." )

parser.add_argument("-f", "--format",
                    action="store",
                    default="yaml",
                    help="File format." )

parser.add_argument("-o", "--output",
                    action="store",
                    default="-",
                    help="Output file",)


args = parser.parse_args()

outfile = args.output



with open(args.infile, 'r') as f:
  text = f.read()

loader = yaml.load
dumper = yaml.dump

if args.format.lower() == 'json':
  loader = json.loads
  dumper = json.dumps


config = readConfig( text, parser=loader )

text = dumper( config )

if outfile == '-':
  print text
else:
  with open(outfile, 'w') as f:
{'fraction_non_alphanumeric': 0.13942093541202671, 'fraction_numerical': 0.0, 'mean_word_length': 2.30780559646539, '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': '1166349', 'n_tokens_mistral': 695, 'n_tokens_neox': 669, 'n_words': 181}