def main(): print sys.argv assert len(sys.argv) >= 2, "usage: python main.py [filename.py]" file_list = sys.argv[1:] suggest_trie = Trie() for filename in file_list: variable_set, class_set, method_set, name_freq = analyze_code(filename) for name in variable_set: suggest_trie.insert(name, name_freq[name]) interactive_suggestion(suggest_trie)
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
def main(): print sys.argv assert len(sys.argv) >= 2, "usage: python main.py [filename.py]" file_list = sys.argv[1:] suggest_trie = Trie() for filename in file_list: variable_set, class_set, method_set, name_freq = analyze_code(filename) for name in variable_set: suggest_trie.insert(name, name_freq[name]) interactive_suggestion(suggest_trie) def interactive_suggestion(suggest_trie): while True: query = raw_input('Enter query: ') if query == 'exit': break else: print suggest_trie.autocomplete(query) if __name__ == "__main__": name_freq = scan_dir('/tmp/exp_dir', analyze_code) suggest_trie = Trie() for name in name_freq: suggest_trie.insert(name, name_freq[name]) interactive_suggestion(suggest_trie)