def filtering_test_code_only(src, dst): progress = 0 test_code_count = 0 if not os.path.isdir(dst): os.mkdir(dst) project_only_test = set() for javafile in java_files_from_dir(src): progress += 1 if progress % 1000 == 0: print 'Parsing: ', progress if ('test' or 'tests' ) in javafile.split('/'): # and 'test' in javafile.split('/')[-1]: test_code_count += 1 project_path = '/'.join(javafile.split('/')[:7]) project_only_test.add(project_path) write_file('/Users/Falcon/Desktop/projects_with_test_code_only.txt', project_path) progress = 0 for i in project_only_test: progress = progress + 1 if progress % 1000 == 0: print 'Copy: ', progress target_destination_detail = dst + i.split('/')[6] if not os.path.isdir(target_destination_detail): os.mkdir(target_destination_detail) copytree(i, target_destination_detail) else: print 'The directory is already existing..' for javafile in java_files_from_dir(dst): if not ('test' or 'Test') in javafile.split('/'): os.remove(javafile)
def __init__(self, github_items, hit_logs_for_each, score_logs_for_each, count): self.hashes = set() self.items = [] self.global_matched_terms = [] self.load_gitsearch_items(github_items) print "Search Count : ", len(self.items) hit_logs_for_each += str(len(self.items)) write_file(hitlog_path, hit_logs_for_each + '\t') score_final_path = '' score_final_path += scorelog_path + str(count) + '.txt' if not os.path.exists(scorelog_path): os.makedirs(scorelog_path) write_file(score_final_path, score_logs_for_each + '\n') self.rank_by_multiplication_score()
def run(name=None): total_time = time.time() if not os.path.exists(scorelog_path): os.makedirs(scorelog_path) targets = read_content_in_file(base_path + "targets_for_recommendation_test.txt") for query_number in targets.splitlines(): hit_logs_for_each = '' score_logs_for_each = '' run.counter += 1 print '[%s] : [%d] / [%d] : ' % ( str(query_number), run.counter, len(targets.split('\n'))), round( (float(run.counter) / float(len(targets.split('\n'))) * 100), 2), '%', 'In progress..' target_file = base_path + "targets/" + query_number + ".txt" code_query = read_content_in_file(target_file) code_query = cgi.escape(re.sub(r'[^\x00-\x80]+', '', code_query)) #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!현재 이코드, 추천안하는 것들을 저장하지 않는다... try: if code_query: search_time = time.time() final_items, hit_logs_for_each, score_logs_for_each = query_index( code_query, hit_logs_for_each, score_logs_for_each) git_search_result = GitSearch_Result_speed_1.GitSearchResult( final_items) for i in git_search_result.items: # print u'************************************************', i.file_name save_experiment_result(query_number, i.file_name.split('.')[0]) if not git_search_result.items: save_experiment_result(query_number, '0') write_file(hitlog_path, hit_logs_for_each) score_final_path = scorelog_path + query_number + '.txt' write_file(score_final_path, score_logs_for_each + '\n') print("Item Searching Time : %s seconds" % (time.time() - search_time)) print('Total Time Taken : %s seconds' % (time.time() - total_time)) print "***********************************************************************************" except: hit_logs_for_each += '0' # java lexer recursion limit exceeded write_file(hitlog_path, hit_logs_for_each) score_final_path = scorelog_path + query_number + '.txt' write_file(score_final_path, score_logs_for_each + '\n') save_experiment_result(query_number, '0') print(traceback.format_exc()) print('Total Time Taken : %s seconds' % (time.time() - total_time)) print "***********************************************************************************"
def index(name=None): index.counter += 1 print index.counter query = request.args.get('q') hit_logs_for_each = '' score_logs_for_each = '' try: if query: start_time = time.time() query = cgi.escape(re.sub(r'[^\x00-\x80]+', '', query)) final_items, hit_logs_for_each, score_logs_for_each = query_index( query, hit_logs_for_each, score_logs_for_each) git_search_result = GitSearchResult(final_items, hit_logs_for_each, score_logs_for_each, index.counter) for i in git_search_result.items: print i.file_name search_log = None print("$$$%s\tseconds" % (time.time() - start_time)) return render_template("search.html", query=query, git_search_result=git_search_result, search_log=search_log) except: hit_logs_for_each += '0' # java lexer recursion limit exceeded write_file(hitlog_path, hit_logs_for_each) score_final_path = '' score_final_path = scorelog_path + str(index.counter) + '.txt' if not os.path.exists(scorelog_path): os.makedirs(scorelog_path) write_file(score_final_path, score_logs_for_each + '\n') print(traceback.format_exc()) return render_template("index.html", name=name)
def save_experiment_result(input, string): write_file( base_path + "New_Recommended_Set_2/" + str(input) + "_result.txt", string)
def listing_projects_without_testcode(original, test): for i in os.listdir(original): if i in os.listdir(test): continue else: write_file('/Users/Falcon/Desktop/list.txt', i)