forked from omegaup/omegaup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-dao.py
executable file
·40 lines (30 loc) · 1.11 KB
/
update-dao.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
#!/usr/bin/env python3
# pylint: disable=invalid-name
# This program is intended to be invoked from the console, not to be used as a
# module.
'''A tool that calls the DAO updater.'''
from __future__ import print_function
import argparse
import os
import dao_utils
_OMEGAUP_ROOT = os.path.abspath(os.path.join(__file__, '..', '..'))
def _main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument(
'--script',
type=argparse.FileType('r'),
default=os.path.join(_OMEGAUP_ROOT, 'frontend/database/schema.sql'),
)
args = parser.parse_args()
for dao in dao_utils.generate_dao(args.script.read()):
if dao.file_type == 'dao':
filename = os.path.join(
_OMEGAUP_ROOT, 'frontend/server/src/DAO/Base', dao.filename)
else:
filename = os.path.join(_OMEGAUP_ROOT,
'frontend/server/src/DAO/VO', dao.filename)
with open(filename, 'w', encoding='utf-8') as f:
f.write(dao.contents)
if __name__ == '__main__':
_main()
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4