<commit_before>import sys
import ast
from treewriter import TreeWriter


class GitTreeCreator:
    def __init__(self, output_dir):
        self.output_dir = output_dir
        self.output_file = []
        self.source = ""
        self.root = []

    def read_file(self):
        for line in sys.stdin:
            self.source += line

    def parse_sourcecode(self):
        self.read_file()
        self.write_ast_as_filetree(self.source)

    def write_ast_as_filetree(self, source):
        try:
            self.root = ast.parse(source)
        except:
            pass
        self.output_file = open(self.output_dir, 'w')

        writer = TreeWriter(self.output_file)
        writer.write_tree(self.root)
        self.output_file.close()


def main():
    argvs = sys.argv
    if len(argvs) != 2:
        print "input error"
        print "argv : <Full path of output file>"
        return

    creator = GitTreeCreator(argvs[1])
    creator.parse_sourcecode()

if __name__ == '__main__':
    main()<commit_msg>fixed main function.<commit_after>import sys
import ast
from treewriter import TreeWriter


class GitTreeCreator:
    def __init__(self, output_dir):
        self.output_dir = output_dir
        self.output_file = []
        self.source = ""
        self.root = []

    def read_file(self):
        for line in sys.stdin:
            self.source += line

    def parse_sourcecode(self):
        self.read_file()
        self.write_ast_as_filetree(self.source)

    def write_ast_as_filetree(self, source):
        try:
            self.root = ast.parse(source)
        except:
            pass
        self.output_file = open(self.output_dir, 'w')

        writer = TreeWriter(self.output_file)
        writer.write_tree(self.root)
        self.output_file.close()


def main():
    if len(sys.argv) != 2:
        print('usage : python {} <absolute path of output file>'.format(sys.argv[0]))
        return

    creator = GitTreeCreator(sys.argv[1])
    creator.parse_sourcecode()

if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.10549558390578999, 'fraction_numerical': 0.0024533856722276743, 'mean_word_length': 2.2887096774193547, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2047071', 'n_tokens_mistral': 645, 'n_tokens_neox': 632, 'n_words': 136}