Esempio n. 1
0
def load_trie():
    repo_paths = [os.path.join(REPO_DIR, f) for f in listdir(REPO_DIR)]
    suggest_trie = Trie()
    for path in repo_paths:
        variable_set, class_set, method_set, name_freq = scan_repo(path)
        for name in variable_set:
            suggest_trie.insert(name, name_freq[name], "variable")
        for name in class_set:
            suggest_trie.insert(name, name_freq[name], "class")
        for name in method_set:
            suggest_trie.insert(name, name_freq[name], "method")

    return suggest_trie
Esempio n. 2
0
 def update_repo_word_count_view(self, repo_ref, repo_url):
     # download repo from repo_url
     # scan & analyze repo from the local repo_path
     print "cloning repo from %s" % repo_url
     self.clean_clone_dir()
     git.Repo.clone_from(repo_url, TEMP_REPO_DIR)
     word_freq_by_files = scan_repo(TEMP_REPO_DIR)
     for word in word_freq_by_files:
         files, counts = zip(*word_freq_by_files[word])
         total_freq = sum(counts)
         v = RepoWordCountView(repo=repo_ref, word=word, total=total_freq, counts=counts, files=files, count_in_files=word_freq_by_files[word])
         v.save()
     # remove downloaded repo
     self.clean_clone_dir()