- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
def search_with_city(obj1, obj2, obj3):
print '------------Search by latitude, longitude and city------------'
list1 = []
list_new = []
while True:
line = file_airport.readline().lower()
if obj3 in line:
Str_file = ''.join(line)
List_file2 = Str_file.split(',')
if obj3 in List_file2[7]:
list1.append(List_file2)
for item in list1:
item.append(sqrt((float(item[11]) - float(obj1))**2 + (float(item[12]) - float(obj2))**2))
list_new = sorted(list1, key = lambda x: x[-1], reverse = False)
config = yaml.load(open('findairport.conf'))
outs = config['output']
for List_file in list_new:
if List_file2[3] != List_file[3]:
for out in outs:
out = out % dict(airportcode = str(List_file[0]).upper(), distance = List_file[-1],\
airportname = str(List_file[13]).title(), sa = str(List_file[8]).title(), street = str(List_file[10]).title(),\
city = str(List_file[7]).title(), state = str(List_file[5]).upper(), zip = List_file[3],\
country = str(List_file[2]).upper(), lat = str(List_file[11]), lon = str(List_file[12]+'\n'))
print out
if not line:
break
try:
if not obj1 in line and not obj2 in line and not obj3 in line:
print 'Nothing more is been found'
except:
pass
else:
pass
file_airport.seek(0)