-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
58 lines (53 loc) · 1.54 KB
/
run.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
# -*- coding: utf8 -*-
# test encoding: à-é-è-ô-ï-€
#
## @package openaip2sqlite
# Convert openAIP XML files to SQLite database
#
# Adrien Crovato
def setup(xmldir):
'''Perform basic setup
'''
import sys, os
sys.path.append(os.path.dirname(os.path.realpath(__file__))) # adds "." to the python path
# create output directory
idir = os.path.join(os.getcwd(), xmldir)
odir = os.path.join(os.getcwd(), 'sqlite')
if not os.path.isdir(odir):
print "creating", odir
os.makedirs(odir)
os.chdir(odir)
return idir
def printStart():
import time, socket
print '*' * 79
print '* openaip2sqlite'
print '* Adrien Crovato, June 2020'
print '* Distributed under Apache license 2.0'
print '*' * 79
print 'time:', time.strftime('%c')
print 'hostname:', socket.gethostname()
print '*' * 79
def printEnd():
print '*' * 79
print 'Job done!'
print '*' * 79
def main(verbose, xmldir, airac):
import tools.manager as man
# start
xmlpath = setup(xmldir)
printStart()
# run
manager = man.Manager(airac, xmlpath, verbose)
manager.run()
# end
printEnd()
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--verbose', help='print parsed data to console', action="store_true")
parser.add_argument('dir', help='xml source directory')
parser.add_argument('a', help='AIRAC number')
args = parser.parse_args()
main(args.verbose, args.dir, args.a)