Skip to content

Commit f89adce

Browse files
committed
Add missing file.
1 parent 3e505f4 commit f89adce

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

build/_sandbox.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/python3
2+
3+
from os.path import *
4+
import argparse
5+
import os
6+
import shutil
7+
8+
9+
def main():
10+
parser = argparse.ArgumentParser()
11+
parser.add_argument("-s", "--sandbox")
12+
parser.add_argument("-v", "--verbose", action="store_true")
13+
parser.add_argument("-l", "--link", action="store_true")
14+
parser.add_argument("-e", "--export", action="store_true")
15+
parser.add_argument("files", nargs="*")
16+
args = parser.parse_args()
17+
18+
assert args.sandbox, "You must specify a sandbox directory"
19+
assert args.link ^ args.export, "You can't link and export at the same time"
20+
21+
if args.link:
22+
os.makedirs(args.sandbox, exist_ok=True)
23+
for f in args.files:
24+
sf = join(args.sandbox, f)
25+
if args.verbose:
26+
print("link", sf)
27+
os.makedirs(dirname(sf), exist_ok=True)
28+
try:
29+
os.link(abspath(f), sf)
30+
except PermissionError:
31+
shutil.copy(f, sf)
32+
33+
if args.export:
34+
for f in args.files:
35+
sf = join(args.sandbox, f)
36+
if args.verbose:
37+
print("export", sf)
38+
df = dirname(f)
39+
if df:
40+
os.makedirs(df, exist_ok=True)
41+
os.rename(sf, f)
42+
43+
44+
main()

0 commit comments

Comments
 (0)