forked from KyotoUx/koala_lang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy.py
executable file
·52 lines (39 loc) · 1.36 KB
/
copy.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
49
50
51
52
#!/usr/bin/env python3.9
from argparse import ArgumentParser
from pathlib import Path
from shutil import copy
PATTERN = "edx-platform.*"
HERE = Path(__file__).parent.resolve()
DESCRIPTION ='This script copies ".po" file under specific directory. use like: `./copy.py . ./dist && cp -r ./dist/* "$(tutor config printroot)/env/build/openedx/locale/ja-jp/LC_MESSAGES"'
def parse_args() -> tuple[Path, Path]:
parser = ArgumentParser(epilog=DESCRIPTION)
parser.add_argument(
"--src",
type=Path,
default=HERE,
help="Path to source directory, default is . (repository root)",
)
parser.add_argument(
"--dist",
type=Path,
default=HERE / "dist",
help="Path to distribution directory, default is ./dist",
)
args = parser.parse_args()
return args.src, args.dist
def copy_files(src: Path, dist: Path):
for p in src.glob(PATTERN):
po_file = p / "ja_JP.po"
filename = po_file.parent.name.removeprefix(PATTERN.removesuffix("*")) + ".po"
if po_file.exists():
dest = dist / filename
copy(po_file, dest)
print(f"COPY: {po_file} -> {dest}")
def main():
src, dist = parse_args()
if not dist.exists():
print(f"{dist} dose not exists, making")
dist.mkdir()
copy_files(src, dist)
if __name__ == "__main__":
main()