Exemple #1
0
 def show_table(self, event):
     code = self.tc.GetValue().upper()
     if code == '':
         return self.info('Please Enter the Airport Code!')
     airline = self.tc2.GetValue().upper()
     location = self.tc3.GetValue()
     flight_num = self.tc4.GetValue()
     result = 'dep/' + code + '_DEP.pkl'
     # print(self.onChecked)
     if test.check_data(code, '0') is False:
         return self.info('The current Airport is not in the Library')
     else:
         df = pd.read_pickle(result)
         if airline != '':
             df = fx.search_by_airline(df, airline)
         if location != '':
             df = fx.search_location(df, location)
         if flight_num != '':
             df = fx.search_flight_num(df, flight_num)
         if self.cbcs is False:
             if self.cbnc is False:
                 return table.main(df)
             else:
                 return table.main(fx.no_cargo(df))
         else:
             if self.cbnc is False:
                 return table.main(fx.no_codeshare(df))
             else:
                 df = fx.no_codeshare(df)
                 return table.main(fx.no_cargo(df))
Exemple #2
0
 def advanced_search(self, e):
     text = self.search.GetValue()
     if len(text) <= 1:
         return self.info('You need provide more information!')
     method = self.rbox.GetStringSelection()
     if method == 'Airport':
         df = pd.read_pickle('airports.pkl')
         if (len(text) <= 4) and (text.isupper() == True):
             df = df[(df.AirportIATA.str.contains(text, na=False)) | (df.AirlineICAO.str.contains(text, na=False))]
         else:
             df = df[(df.Airport_Name.str.contains(text, na=False)) | (df.Ariport_City.str.contains(text, na=False))]
         return table.main(df)
     if method == 'Airline':
         df = pd.read_pickle('airlines.pkl')
         df = df[(df.AirlineIATA.str.contains(text, na=False))|(df.AirlineICAO.str.contains(text, na=False))|(df.Airline.str.contains(text, na=False))]
         return table.main(df)
Exemple #3
0
 def show_table(self, event):
     code = self.search.GetValue().upper()
     method = self.rbox.GetStringSelection()
     choice = str(self.combo.GetSelection() + 1)
     if method == "Departure":
         selection = "0"
     if method == "Arrival":
         selection = "1"
     if code == '':
         return self.info('Please Enter the Airport Code!')
     if (len(code) != 3) or (code.isalpha() is False):
         return self.info('This is a invalid Airport Code!')
     if choice == "9":
         df = dldata.download_all(code, selection)
     else:
         df = dldata.ontime(code, choice, selection)
     #filter
     airline = self.search3.GetValue().upper()
     location = self.search2.GetValue()
     flight_num = self.search4.GetValue()
     if airline != '':
         df = fx.search_by_airline(df, airline)
     if location != '':
         df = fx.search_location(df, location, selection)
     if flight_num != '':
         df = fx.search_flight_num(df, flight_num)
     if self.cbcs is False:
         if self.cbnc is False:
             return table.main(df)
         else:
             return table.main(fx.no_cargo(df))
     else:
         if self.cbnc is False:
             return table.main(fx.no_codeshare(df))
         else:
             df = fx.no_codeshare(df)
             return table.main(fx.no_cargo(df))
Exemple #4
0
 def closest(self, event):
     df = self.data
     me = self.search.GetValue().upper()
     airports = pd.read_pickle("airports.pkl")
     distance = df.loc[:, ['City', 'Country', 'AirportIATA', 'Airport_Name', 'Latitude', 'Longitude']]
     distance = distance.drop_duplicates()
     lat = list(airports[airports.AirportIATA == me].Latitude.values)[0]
     long = list(airports[airports.AirportIATA == me].Longitude.values)[0]
     distance['Distance (km)'] = ''
     for indexs in distance.index:
         a = distance.loc[indexs].values[4]
         b = distance.loc[indexs].values[5]
         distance["Distance (km)"][indexs] = round(geodesic((lat, long), (a, b)).km, 2)
     d = distance.sort_values(by='Distance (km)', ascending=False).tail(10)
     return table.main(d)
Exemple #5
0
 def show_table(self, event):
     return table.main(self.data)
Exemple #6
0
from table import main, generate_surfaces
main()
Exemple #7
0
 fix_links = get_fix_links(this_page)
 text_for_table = ''
 line_continue = True
 for el in fix_links:
     if line_continue == True:
         line_continue = False
         continue
     ready_line = ''
     for item in el.select('td'):
         ready_line = ready_line + item.text + '\t'
     text_for_table = text_for_table + ready_line + '\n'
 table_file = open('table.txt', 'w', encoding="utf-8")
 table_file.write(text_for_table)
 table_file.close()
 table_file = open('table.txt', 'r', encoding="utf-8")
 table_text = table.main(table_file)
 table_file.close()
 result_text = template
 result_text = result_text.replace('$text', this_page_text)
 result_text = result_text.replace('$sub_text', sub_text)
 result_text = result_text.replace('$name', model.text)
 result_text = result_text.replace('$table', text_for_table)
 result_text = result_text.replace('$fix_links', table_text)
 shutil.copytree(os.getcwd() + '\\' + 'files', folder_to_create)
 result_file = open(os.getcwd() + '\\' + folder_to_create + '\\' +
                    'index.txt',
                    'w',
                    encoding="utf-8")
 result_file.write(result_text)
 result_file.close()
 os.rename(os.getcwd() + '\\' + folder_to_create + '\\' + 'index.txt',
Exemple #8
0
def main_frame(right, login, passwd):
    root.destroy()
    main(right, login, passwd)