1. Python / Говнокод #8824

    −86

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 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)

    PHP'шники наступают! :)

    Запостил: stalk, 14 Декабря 2011

    Комментарии (6) RSS

    Добавить комментарий