Debian Codegraph @

tests/fuzzing/create_dict_corpus_file.py

raw symbols SCIP
1 #!/bin/python3
2 # /*
3 # * Copyright (C) 2022 Anna Stan , Mamaodou Dramé Kalilou , Nicolas Morel
4 # *
5 # * This program is free software; you can redistribute it and/or modify
6 # * it under the terms of the GNU General Public License as published by
7 # * the Free Software Foundation; either version 3 of the License, or
8 # * (at your option) any later version.
9 # *
10 # * This program is distributed in the hope that it will be useful,
11 # * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # * GNU General Public License for more details.
14 # *
15 # * You should have received a copy of the GNU General Public License
16 # * along with this program; if not, see: <http://www.gnu.org/licenses/>.
17 # */
18 import sys
19 import mmap
20 import argparse
21 import shutil
22 import os
23 from os import O_RDONLY, O_RDWR, O_WRONLY, O_TRUNC, O_CREAT, SEEK_END, SEEK_CUR, SEEK_SET
24
25 def main(argc, argv):
26 if argc < 2:
27 print('Summary: add file to the corpus ', file=sys.stderr)
28 print(f'Usage: {argv[0]} -c <corpus_dir>', file=sys.stderr)
29 exit(1)
30
31 ap = argparse.ArgumentParser()
32
33 # Add the arguments to the parser
34 ap.add_argument("-c", "--corpus_dir", required=True,
35 help="corpus directory where to add the file")
36 args = vars(ap.parse_args())
37
38
39 lang_list=os.getenv("FUZZ_VOICE")
40 if(lang_list):
41 list=lang_list+"_list"
42 else:
43 list="en_list"
44 output_name = list+"_dict_corpus.txt"
45 output_path=args['corpus_dir']+output_name
46 output= open(output_path, "w")
47
48 path="../../dictsource/"+list
49
50
51 file = open( path, "r")
52 lines=file.readlines()
53 index=1
54 for line in lines:
55 if line[0]=='/' and line[1]=='/':
56 continue
57 res = line.split()
58 if len(res):
59 output.write("kw")
60 output.write(str(index))
61 index=index+1
62 output.write("=")
63 output.write(res[0])
64 output.write('\n')
65 file.close()
66 output.close()
67 if __name__ == "__main__":
68 main(len(sys.argv), sys.argv)