-
Notifications
You must be signed in to change notification settings - Fork 9
/
move_build.py
48 lines (42 loc) · 1.91 KB
/
move_build.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
47
48
import shutil
import os
import os.path as path
import stat
if __name__ == '__main__':
import argparse
def parse_args():
parser = argparse.ArgumentParser(
prog='move_build.py',
formatter_class=argparse.RawDescriptionHelpFormatter,
description='move built code into its own directory',
epilog="""Example usage:
$ python move_build english /path/to/out/
makes a new directory (will overwrite if it exists!) and moves the code
for the evaluation of the english dataset there.
""")
parser.add_argument('corpus', metavar='CORPUS',
nargs=1,
choices=['sample', 'english', 'xitsonga'],
help='build code for which corpus')
parser.add_argument('output', metavar='OUTDIR',
nargs=1,
help='output directory (will be overwritten if it exists)')
return vars(parser.parse_args())
args = parse_args()
corpus = args['corpus'][0]
output = args['output'][0]
if path.exists(output):
shutil.rmtree(output)
shutil.copytree('build/exe.linux-x86_64-2.7', path.join(output, 'resources/'))
shutil.copytree('bin/resources', path.join(output, 'resources/resources'))
if corpus == 'sample':
shutil.copy('sample_eval2', path.join(output, 'sample_eval2'))
shutil.copy('bin/resources/sample.classes.example',
path.join(output, 'sample.classes.example'))
os.chmod(path.join(output, 'sample_eval2'), stat.S_IRUSR | stat.S_IXUSR)
elif corpus == 'english':
shutil.copy('english_eval2', path.join(output, 'english_eval2'))
os.chmod(path.join(output, 'english_eval2'), stat.S_IRUSR | stat.S_IXUSR)
else:
shutil.copy('xitsonga_eval2', path.join(output, 'xitsonga_eval2'))
os.chmod(path.join(output, 'xitsonga_eval2'), stat.S_IRUSR | stat.S_IXUSR)