Debian Codegraph @

scripts/mk_pat_db.py

raw
1 # -- /usr/bin/env python
2 """
3 Reads a pattern database and generates the corresponding
4 header file.
5 """
6 import mk_genfile_common
7 import argparse
8 import logging
9 import os
10 import sys
11
12 def main(args):
13 logging.basicConfig(level=logging.INFO)
14 parser = argparse.ArgumentParser(description=__doc__)
15 parser.add_argument("db_file", help="pattern database file")
16 parser.add_argument("output_file", help="output header file path")
17 pargs = parser.parse_args(args)
18
19 if not os.path.exists(pargs.db_file):
20 logging.error('"{}" does not exist'.format(pargs.db_file))
21 return 1
22
23 mk_genfile_common.mk_pat_db_internal(pargs.db_file, pargs.output_file)
24 logging.info('Generated "{}"'.format(pargs.output_file))
25 return 0
26
27 if __name__ == '__main__':
28 sys.exit(main(sys.argv[1:]))
29