<commit_before>from web import visualizer
import sys
import os
from git import *


def main(argv):
    opt = argv[0]
    if opt == "getRepo":
        if not os.path.isdir("./Target"):
            os.mkdir("Target")
        Repo.clone_from(argv[1], "./Target")
    elif opt == "gitLog":
        
        print "do git log"
    elif opt == "PMD":
        print "do PMD"
    elif opt == "Parse":
        print "do parse"
    elif opt == "GenerateJSON":
        print "do GenerateJSON"
    elif opt == "GenerateGraph":
        visualizer.begin()



    else:
        usage()

def PMD(argv):

    print "do PMD"



def usage():
    print "Usage: Main.py <option> "
    print "option  :      getRepo <git repo address> - perform 'git pull' with given repoURL at ./target"
    print "               gitLog                     - generate gitLog.xml in PMDResult"
    print "               PMD                        - analyze target/ with PMD. place xml results in PMDResults"
    print "               Parse                      - execute parsers to parse result within PMDResults"
    print "               GenerateJSON               - generate JSON from the fuser "
    print "               GenerateGraph              - generate the result with D3 using JSON"

if __name__ == "__main__":
    main(sys.argv[1:])


<commit_msg>updated Main.py with 1. generate gitLog.txt from git log --stat 2. mock PMD execution<commit_after>from web import visualizer
import sys
import os
import shutil
from git import *


def main(argv):
    opt = argv[0]
    if opt == "getRepo":
        try:
            git_pull(argv[1])
        except Exception, e:
            print (str(e))
    elif opt == "gitLog":
        git_log()
    elif opt == "PMD":
        PMD()
    elif opt == "Parse":
        print "do parse"
    elif opt == "GenerateJSON":
        print "do GenerateJSON"
    elif opt == "GenerateGraph":
        visualizer.begin()
    else:
        usage()



def git_pull(git_dir):
    if not os.path.isdir("./Target"):
        os.mkdir("Target")
        Repo.clone_from(git_dir, "./Target")
    else:
        print "/Target folder exist, please remove it to get new repository"

def git_log():
    g = Git('./Target/')
    gitLog = g.log("--reverse","--stat")
    with open('./PMDResult/gitLog.txt','w') as r:
        r.write(gitLog)
    print ("gitLog.txt is placed in PMDResult")

def PMD():
    g = Git('./Target/')
    commits = g.log("--reverse", "--pretty=%h").split("\n")
    for c in commits:
        print ("git checkout -b " + c)
        print ("Execute PMD on commit: " + c)




def usage():
    print "Usage: Main.py <option> "
    print "option: getRepo <git repo address> - perform 'git pull' with given repoURL at ./target"
    print "        gitLog                     - generate gitLog.xml in PMDResult"
    print "        PMD                        - analyze target/ with PMD. place xml results in PMDResults"
    print "        Parse                      - execute parsers to parse result within PMDResults"
    print "        GenerateJSON               - generate JSON from the fuser "
    print "        GenerateGraph              - generate the result with D3 using JSON"
#
if __name__ == "__main__":
    if len(sys.argv) == 1:
        usage()
    else:
        main(sys.argv[1:])



{'fraction_non_alphanumeric': 0.1151625645700395, 'fraction_numerical': 0.003342449103615922, 'mean_word_length': 1.7827557058326289, 'pattern_counts': {'":': 14, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2412153', 'n_tokens_mistral': 979, 'n_tokens_neox': 954, 'n_words': 322}