-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeo.py
33 lines (25 loc) · 905 Bytes
/
geo.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
import argparse
from CountryClass import CountryClass
from AreaClass import AreaClass
parser = argparse.ArgumentParser(description='Parse http://www.geonames.org data based on country or city in country')
parser.add_argument('country',
help='Country name for which parse cities. This is mandatory argument.')
parser.add_argument('username',
help='Api username. This is mandatory argument.')
parser.add_argument('--id',
help='Place id from geonames')
args = parser.parse_args()
country = args.country.lower()
username = args.username.lower()
if args.id is not None:
id = args.id.lower()
else:
id = ''
if id is not '':
print("Parse "+country + " area by id: " + id)
area = AreaClass(id, username, country)
area.parse()
else:
print("Parse country: " + country)
parser = CountryClass()
parser.parse(country)