|
| 1 | +from art import * |
| 2 | +import pandas as pd |
| 3 | +import requests |
| 4 | +from prompt_toolkit import prompt |
| 5 | +from prompt_toolkit.completion import FuzzyWordCompleter |
| 6 | +from sys import exit |
| 7 | + |
| 8 | + |
| 9 | +class Visa_Status: |
| 10 | + def __init__(self, download_url, resident_country): |
| 11 | + tprint("VISA-CLI") |
| 12 | + print("Downloading Visa data...\n") |
| 13 | + self.download_url = download_url |
| 14 | + self.resident_country = resident_country |
| 15 | + |
| 16 | + # Generate Country dataframe |
| 17 | + # -------------------------- |
| 18 | + # passport_csv = requests.get(self.download_url) |
| 19 | + # passport_df = pd.read_csv(passport_csv) |
| 20 | + |
| 21 | + passport_df = pd.read_csv(self.download_url) |
| 22 | + # Transpose the selected data |
| 23 | + country_data_df = passport_df[ |
| 24 | + passport_df["Passport"] == resident_country |
| 25 | + ].transpose() # Select |
| 26 | + country_data_df = country_data_df.iloc[1:] # Delete first two rows |
| 27 | + |
| 28 | + # Reset the index and rename the column names |
| 29 | + country_data_df = country_data_df.reset_index() |
| 30 | + country_data_df.columns = ["Country", "Status"] |
| 31 | + self.country_data_df = country_data_df |
| 32 | + |
| 33 | + def get_status_vf(self): |
| 34 | + """Get Countries that doesn't need a Visa """ |
| 35 | + |
| 36 | + visa_free_df = self.country_data_df[ |
| 37 | + self.country_data_df["Status"] == "visa free" |
| 38 | + ] |
| 39 | + return visa_free_df |
| 40 | + |
| 41 | + def get_status_vr(self): |
| 42 | + """Get Countries that needs a Visa""" |
| 43 | + |
| 44 | + visa_required_df = self.country_data_df[ |
| 45 | + self.country_data_df["Status"] == "visa required" |
| 46 | + ] |
| 47 | + return visa_required_df |
| 48 | + |
| 49 | + def get_status_voa(self): |
| 50 | + """Get Countries that permits Visa On Arrival""" |
| 51 | + |
| 52 | + visa_on_arrival_df = self.country_data_df[ |
| 53 | + self.country_data_df["Status"] == "visa on arrival" |
| 54 | + ] |
| 55 | + return visa_on_arrival_df |
| 56 | + |
| 57 | + def get_status_eta(self): |
| 58 | + """Get Countries offering Electronic Travel Authority""" |
| 59 | + |
| 60 | + # eta - electronic travel authority |
| 61 | + visa_eta_df = self.country_data_df[self.country_data_df["Status"] == "e-visa"] |
| 62 | + return visa_eta_df |
| 63 | + |
| 64 | + def get_status_vfe(self): |
| 65 | + """Get Countries offering Visa Free Days """ |
| 66 | + |
| 67 | + visa_free_days_df = self.country_data_df[ |
| 68 | + pd.to_numeric(self.country_data_df["Status"], errors="coerce").notnull() |
| 69 | + ] |
| 70 | + return visa_free_days_df |
| 71 | + |
| 72 | + def get_covid_ban(self): |
| 73 | + """Get Countries that banned visa due to covid""" |
| 74 | + visa_covid_ban = self.country_data_df[ |
| 75 | + self.country_data_df["Status"] == "covid ban" |
| 76 | + ] |
| 77 | + |
| 78 | + return visa_covid_ban |
| 79 | + |
| 80 | + def interactive_prompt(self): |
| 81 | + """Interactive Prompt to offer Visa status""" |
| 82 | + countries_list = self.country_data_df["Country"].to_list() |
| 83 | + print("Press Any Key to Exit!") |
| 84 | + while True: |
| 85 | + country_completer = FuzzyWordCompleter(countries_list) |
| 86 | + print("\n") |
| 87 | + |
| 88 | + selected_country = prompt( |
| 89 | + "Destination Country:", completer=country_completer |
| 90 | + ) |
| 91 | + |
| 92 | + selected_country_status = self.country_data_df[ |
| 93 | + self.country_data_df["Country"] == selected_country |
| 94 | + ] |
| 95 | + |
| 96 | + try: |
| 97 | + print(selected_country_status["Status"].to_list()[0]) |
| 98 | + except: |
| 99 | + print("Exiting...\n") |
| 100 | + exit() |
0 commit comments