-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathremove_code.py
36 lines (27 loc) · 1.01 KB
/
remove_code.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
"""
Example:
python ./remove_code.py -o ./NotCompiledTables2015.txt
"""
import os
import lib.nav_table_parser as ntp
from lib.models import Table, Field
import lib.nav_table_editor as nte
import argparse
from pathlib import Path
parser = argparse.ArgumentParser()
parser.add_argument('-o','--original',help='original text file', required=True)
parser.add_argument('-r','--result',help='file name for result')
args = parser.parse_args()
if not Path(args.original).exists():
raise argparse.ArgumentTypeError("File {} was not found.".format(args.original))
original_file = args.original
if args.result:
result_file = args.result
else:
(file_name, file_extention) = os.path.splitext(original_file)
result_file = file_name + '_Without_Code' + file_extention
print("Processing file {} ...".format(original_file))
original_tables = ntp.populate_table_list(original_file)
print("Creating file {} ...".format(result_file))
nte.create_file_without_code(original_file, result_file, original_tables)
print("Done.")