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

# Author: <NAME> < <EMAIL> >
# License: New BSD License (See LICENSE)

import argparse
import os
import sys

import bracoujl.graph as bg
import bracoujl.writers.dotwriter as bwd
#import bracoujl.writers.asciiwriter

def main():
    parser = argparse.ArgumentParser(description='Some debugging tool.')
    parser.add_argument('-o', '--output-dir', action='store', required=True,
                        metavar='dir', help='output directory')
    parser.add_argument('log', action='store', nargs='+',
                        help='log file correctly formatted')
    args = parser.parse_args(sys.argv[1:])

    output_dir = os.path.abspath(args.output_dir)
    if not os.path.exists(output_dir):
        msg = 'I didn\'t find directory/symbolic link named `{path}` where '
        msg += 'to generate the graphs.'
        sys.exit(msg.format(path=output_dir))

    for log in args.log:
        functions = bg.Graph().generate_graph(log)
        print('Found {} functions:'.format(len(functions)))

        dw = bwd.DotWriter()
        for function in functions:
            print(' - {}'.format(function.name()))
            if function.name() in ['sub_0216', 'int_0010']:
                with open(os.path.join(output_dir, function.uniq_name() + '.dot'), 'w') as f:
                    dw.generate_graph(f, function)

if __name__ == '__main__':
    main()<commit_msg>YOU GET A GRAPH! YOU GET A GRAPH! EVERYBODY GETS A GRAAAAPH!<commit_after>#! /usr/bin/env python

# Author: <NAME> < <EMAIL> >
# License: New BSD License (See LICENSE)

import argparse
import os
import subprocess
import sys

import bracoujl.graph as bg
import bracoujl.writers.dotwriter as bwd
#import bracoujl.writers.asciiwriter

def main():
    parser = argparse.ArgumentParser(description='Some debugging tool.')
    parser.add_argument('-o', '--output-dir', action='store', required=True,
                        metavar='dir', help='output directory')
    parser.add_argument('log', action='store', nargs='+',
                        help='log file correctly formatted')
    args = parser.parse_args(sys.argv[1:])

    output_dir = os.path.abspath(args.output_dir)
    if not os.path.exists(output_dir):
        msg = 'I didn\'t find directory/symbolic link named `{path}` where '
        msg += 'to generate the graphs.'
        sys.exit(msg.format(path=output_dir))

    for log in args.log:
        functions = bg.Graph().generate_graph(log)
        print('Found {} functions:'.format(len(functions)))

        dw = bwd.DotWriter()
        for function in functions:
            print(' - {}'.format(function.name()))
            dot_name = os.path.join(output_dir, function.uniq_name() + '.dot')
            with open(dot_name, 'w') as f:
                dw.generate_graph(f, function)
            subprocess.call(['dot', '-Tsvg', dot_name, '-o', dot_name[:-4] + '.svg'])

if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.14358974358974358, 'fraction_numerical': 0.0037606837606837607, 'mean_word_length': 2.8652575957727873, 'pattern_counts': {'":': 0, '<': 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': '605820', 'n_tokens_mistral': 939, 'n_tokens_neox': 900, 'n_words': 223}