-
Notifications
You must be signed in to change notification settings - Fork 2
/
copy_files.py
46 lines (34 loc) · 1.69 KB
/
copy_files.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import shutil
import os
def find_directory(prefix, parent, project):
dir = ''
for file in os.listdir(parent):
if file.startswith(prefix):
if dir:
prompt = "You have more than one project " + project + " directory. Please enter the name of your directory (ex. fa23-proj2-githubusername)"
user_input = input(prompt)
return find_directory(user_input, parent, project)
else:
dir = os.path.join(parent,file)
if dir == '':
prompt = "We could not find your project " + project + " directory. Please enter the name of your directory (ex. fa23-proj2-githubusername)"
user_input = input(prompt)
return find_directory(user_input, parent, project)
return dir
def copy_files():
cwd = os.getcwd()
parent = os.path.abspath(os.path.join(cwd, os.pardir))
proj2_prefix = 'fa23-proj2-'
proj3_prefix = 'fa23-proj3-'
proj2_dir = find_directory(proj2_prefix, parent, "2")
proj3_dir = find_directory(proj3_prefix, parent, "3")
db_path = 'src/main/java/edu/berkeley/cs186/database/'
proj2_files = [os.path.join(db_path,'index',p + '.java') for p in ['BPlusTree', 'InnerNode', 'LeafNode', 'BPlusNode']]
proj3_files = [os.path.join(db_path,'query',p + '.java') for p in ['join/BNLJOperator', 'SortOperator', 'join/SortMergeOperator', 'join/GHJOperator', 'QueryPlan']]
for file_name in proj2_files:
source_file = os.path.join(proj2_dir, file_name)
shutil.copy(source_file, file_name)
for file_name in proj3_files:
source_file = os.path.join(proj3_dir, file_name)
shutil.copy(source_file, file_name)
copy_files()