forked from awslabs/damo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
damo_translate_damos.py
36 lines (28 loc) · 1.01 KB
/
damo_translate_damos.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
# SPDX-License-Identifier: GPL-2.0
"""
Convert old damos schemes to json format.
"""
import argparse
import json
import _damo_deprecated
import _damo_deprecation_notice
def set_argparser(parser):
parser.add_argument('schemes', metavar='<file or string>',
help='schemes in old .damos format')
def main(args=None):
if not args:
parser = argparse.ArgumentParser()
set_argparser(parser)
args = parser.parse_args()
_damo_deprecation_notice.will_be_deprecated('translate_damos', '2023-Q4',
'Use the command of <=v2.0.2 DAMO instead.')
_damo_deprecated.avoid_crashing_single_line_scheme_for_testing = True
_damo_deprecated.avoid_crashing_v1_v3_schemes_for_testing = True
schemes, err = _damo_deprecated.damo_single_line_schemes_to_damos(
args.schemes)
if err:
print('failed --schemes parsing (%s)' % err)
exit(1)
print(json.dumps([scheme.to_kvpairs() for scheme in schemes], indent=4))
if __name__ == '__main__':
main()