import sys
import re
import pprint
import os.path

from collections import defaultdict

from checkmate.management.helpers import analyze_file,aggregate_statistics,get_files_list
from checkmate.settings import analyzers,aggregators

if __name__ == '__main__':
    path = os.path.abspath(sys.argv[1])
    filenames = get_files_list(path)

    file_stats = {}
    file_issues = {}

    for filename in filenames:

        file_stats[filename],file_issues[filename] = analyze_file(path+filename,analyzers)

    project_stats = aggregate_statistics(file_stats,analyzers,aggregators)

    pprint.pprint(dict(project_stats))
