def cgum(src_path, file_hash, success_count): dest_path = meta_path + str(success_count) + '_' + file_hash + '.html' if os.path.exists(src_path): st = "/mnt/storage/falconlk/cgum/cgum parse %s > %s" % (src_path, dest_path) my_env = os.environ.copy() my_env[ "PATH"] = "/home/falconlk/.linuxbrew/bin:/home/falconlk/.linuxbrew/sbin:/mnt/storage/falconlk/gumtree/dist/build/distributions/gumtree/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/opt/dell/srvadmin/bin:/mnt/storage/falconlk/cgum" + \ my_env["PATH"] Popen(st, env=my_env, shell=True) else: write_file(meta_path + 'no_before_file_forCgum.txt', src_path) return dest_path
def gumtree(src_path): dest_path = '/'.join(src_path.split('/')[:-1]) + '/' + src_path.split( '/')[-1].split('.')[0] + '.json' # st = "/mnt/storage/falconlk/cgum/cgum parse %s > %s" % (src_path, dest_path) if os.path.exists(src_path): st = "/mnt/storage/falconlk/gumtree/dist/build/distributions/gumtree/bin/gumtree parse %s > %s" % ( src_path, dest_path) my_env = os.environ.copy() my_env[ "PATH"] = "/home/falconlk/.linuxbrew/bin:/home/falconlk/.linuxbrew/sbin:/mnt/storage/falconlk/gumtree/dist/build/distributions/gumtree/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/opt/dell/srvadmin/bin:/mnt/storage/falconlk/cgum" + my_env[ "PATH"] Popen(st, env=my_env, shell=True) else: write_file(meta_path + 'no_before_file_error.txt', src_path) return dest_path
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..' if __name__ == '__main__': src = '/Users/Falcon/Desktop/GitArchive/Git_testcode_only/' # refineDirectories(src) # check_for_duplicates(src) # rm_dup(src) # javafiles = java_files_from_dir(src) # count = 0 # for i in javafiles: # count += 1 # # print count aset = set() contents = read_file( '/Users/Falcon/Desktop/projects_with_test_code_only.txt') for i in contents.split('\n'): aset.add(i) for i in aset: write_file('/Users/Falcon/Desktop/projects_test_code_only.txt', i) pass
file_hash_string = str(row[4]).strip() print('File hash string: ', file_hash_string) print() sub_before_path = user_repo_ + '/' + commit_hash + '/' + file_hash + '/' + 'before.%s' % (file_name.split('/')[-1].split('.')[-1]) sub_after_path = user_repo_ + '/' + commit_hash + '/' + file_hash + '/' + 'after.%s' % (file_name.split('/')[-1].split('.')[-1]) before_file_path = beaf_path + 'results/' + sub_before_path after_file_path = beaf_path + 'results/' + sub_after_path print(before_file_path) print(after_file_path) print() # Index 2 revising with file existence status if not os.path.exists(before_file_path) and not os.path.exists(after_file_path): write_file(meta_path + 'check.txt', 'X.X') wr.writerow([file_hash, commit_hash, user_repo, file_name, file_hash_string, 'X.X']) elif os.path.exists(before_file_path) and not os.path.exists(after_file_path): write_file(meta_path + 'check.txt', 'O.X') wr.writerow([file_hash, commit_hash, user_repo, file_name, file_hash_string, 'O.X']) elif not os.path.exists(before_file_path) and os.path.exists(after_file_path): write_file(meta_path + 'check.txt', 'X.O') wr.writerow([file_hash, commit_hash, user_repo, file_name, file_hash_string, 'X.O']) elif os.path.exists(before_file_path) and os.path.exists(after_file_path): write_file(meta_path + 'check.txt', 'O.O') wr.writerow([file_hash, commit_hash, user_repo, file_name, file_hash_string, 'O.O']) #####TODO: CPP (srcML) 추가 전까지는 제외 if file_name.split('/')[-1].split('.')[1] == 'cpp': continue
(str_depth, cursor.displayname, str(cursor.kind).split('.')[1], cursor.location.line, cursor.location.column, cursor.location.offset, str(cursor.type.kind).split('.')[1], str(cursor.access_specifier).split('.')[1], cursor.spelling) def nodeTraversePrint(cursor, depth=0): # Node traverse for printing printNode(cursor, depth) for c in cursor.get_children(): nodeTraversePrint(c, depth + 1) def jsonFileLoad(path): with open(path) as f: return json.load(f) if __name__ == "__main__": before_file_path = '.before.c' clang.cindex.Config.set_library_file( '/usr/lib/x86_64-linux-gnu/libclang-6.0.so') index = clang.cindex.Index.create() line_endpos_dict = buildLinePosDict(before_file_path) translation_unit = index.parse(before_file_path) node = nodeTraverseBuild(translation_unit.cursor) nodeTraversePrint(translation_unit.cursor) json_path = '.before.json' write_file(json_path, json.dumps(node, sort_keys=True, indent=4)) tree_before = jsonFileLoad(json_path)
sub_before_path = user_repo_ + '/' + commit_hash + '/' + file_hash + '/' + 'before.%s' % ( file_name.split('/')[-1].split('.')[-1]) sub_after_path = user_repo_ + '/' + commit_hash + '/' + file_hash + '/' + 'after.%s' % ( file_name.split('/')[-1].split('.')[-1]) before_file_path = beaf_path + 'results/' + sub_before_path after_file_path = beaf_path + 'results/' + sub_after_path print(before_file_path) print(after_file_path) print() # Index 2 revising with file existence status if not os.path.exists(before_file_path) and not os.path.exists( after_file_path): write_file(meta_path + 'check.txt', 'X.X') wr.writerow([ file_hash, commit_hash, user_repo, file_name, file_hash_string, 'X.X' ]) elif os.path.exists( before_file_path) and not os.path.exists(after_file_path): write_file(meta_path + 'check.txt', 'O.X') wr.writerow([ file_hash, commit_hash, user_repo, file_name, file_hash_string, 'O.X' ]) elif not os.path.exists(before_file_path) and os.path.exists( after_file_path): write_file(meta_path + 'check.txt', 'X.O') wr.writerow([