comparison globalneighbors/main.py @ 0:5dba84370182

initial commit; half-working prototype
author Jeff Hammel <k0scist@gmail.com>
date Sat, 24 Jun 2017 12:03:39 -0700
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:5dba84370182
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 """
5 locate nearest cities
6 """
7
8 # imports
9 import argparse
10 import json
11 import os
12 import sys
13 import time
14 from .cli import CitiesParser
15 from .locations import locations
16 from .read import read_cities
17 from .schema import fields
18
19 try:
20 # python 2
21 string = (str, unicode)
22 except NameError:
23 # python 3
24 string = (str, )
25
26
27 def main(args=sys.argv[1:]):
28 """CLI"""
29
30 # parse command line options
31 parser = CitiesParser(description=__doc__)
32 options = parser.parse_args(args)
33
34 # read data
35 cities = list(read_cities(options.cities, fields=fields))
36
37 # get locations
38 city_locations = locations(cities)
39
40 # output
41 print (json.dumps(city_locations, indent=2, sort_keys=True))
42
43
44 if __name__ == '__main__':
45 main()
46
47