forked from atcoder/ac-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_zip.py
executable file
·48 lines (38 loc) · 1.47 KB
/
generate_zip.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
#!/usr/bin/env python3
from logging import Logger, basicConfig, getLogger
from os import getenv
from pathlib import Path
from subprocess import run
import zipfile
logger: Logger = getLogger(__name__)
combined_cpp_main = """
int main() {
// write your code here
return 0;
}
"""
if __name__ == "__main__":
basicConfig(
format="%(asctime)s [%(levelname)s] %(message)s",
datefmt="%H:%M:%S",
level=getenv('LOG_LEVEL', 'INFO'),
)
# generate all_combined.cpp
run(['../expander.py', '../atcoder/all', '--lib', '..'])
with open('combined.cpp', 'a') as f:
f.writelines(combined_cpp_main)
# generate zip
with zipfile.ZipFile('ac-library.zip', 'w') as zipf:
langs = ['en', 'ja']
for lang in langs:
for f in (Path('..') / 'document_{}'.format(lang)).glob('*.html'):
zipf.write(f, 'document_{}/'.format(lang) + f.name)
for f in (Path('..') / 'document_{}/lib'.format(lang)).glob('*'):
zipf.write(f, 'document_{}/lib/'.format(lang) + f.name)
for f in (Path('..') / 'document_{}/lib/fonts'.format(lang)).glob('**/*'):
zipf.write(f, 'document_{}/lib/fonts/'.format(lang) + f.name)
for f in (Path('..') / 'atcoder').glob('*'):
zipf.write(f, f.relative_to(Path('..')))
zipf.write('combined.cpp', 'all_combined.cpp');
zipf.write('../expander.py', 'expander.py')
zipf.write('../LICENSE', 'LICENSE')