Skip to content

Commit 86bbe76

Browse files
committed
Initial Commit
0 parents  commit 86bbe76

8 files changed

+322
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__pycache__
2+
venv

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 rand-net
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include *.txt

readme.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# visa-cli
2+
3+
A python script to lookup [Passport Index Dataset](https://github.com/ilyankou/passport-index-dataset)
4+
5+
## Installation
6+
7+
```
8+
git clone
9+
pip install -r requirements.txt
10+
chmod +x visa-cli
11+
visa-cli -f Sweden
12+
13+
```
14+
15+
## Usage
16+
17+
```
18+
19+
usage: visa-cli [-h] [-f] [-r] [-o] [-e] [-n] [-c] [-i] resident_country
20+
21+
positional arguments:
22+
resident_country Current Resident Country
23+
24+
optional arguments:
25+
-h, --help show this help message and exit
26+
-f, --visa-free Countries not requiring Visa
27+
-r, --visa-required Countries requiring Visa
28+
-o, --visa-on-arrival
29+
Countries offering Visa on arrival
30+
-e, --eta Countries offering Electronic Travel Authority
31+
-n, --visa-free-days Countries offering Visa free days
32+
-c, --covid-ban Countries not offering Visa due to Covid-19
33+
-i, --interactive Interactive Prompt
34+
35+
```
36+
37+
* Lookup all Countries offering visa-free travel given a resident Country.
38+
```
39+
visa-cli Germany -f
40+
41+
```
42+
* Lookup all Countries requiring visa given a resident Country.
43+
```
44+
visa-cli China -r
45+
46+
```
47+
* Lookup all Countries offering visa-on-arrival given a resident Country.
48+
```
49+
visa-cli Vatican -o
50+
51+
```
52+
* Lookup all Countries offering ETA(Electronic Travel Authority) given a resident Country.
53+
```
54+
visa-cli Vatican -e
55+
56+
```

requirements.txt

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
art==5.1
2+
certifi==2020.12.5
3+
chardet==4.0.0
4+
idna==2.10
5+
numpy==1.20.1
6+
pandas==1.2.3
7+
prompt-toolkit==3.0.17
8+
python-dateutil==2.8.1
9+
pytz==2021.1
10+
requests==2.25.1
11+
six==1.15.0
12+
urllib3==1.26.4
13+
wcwidth==0.2.5

setup.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import pathlib
2+
from setuptools import setup
3+
4+
HERE = pathlib.Path(__file__).parent
5+
6+
README = (HERE / "README.md").read_text()
7+
8+
# This call to setup() does all the work
9+
setup(
10+
name="visa-cli",
11+
version="0.0.1",
12+
description="CLI tool to lookup Visa status for Countries"
13+
long_description=README,
14+
long_description_content_type="text/markdown",
15+
url="https://github.com/rand-net/visa-cli",
16+
author="rand-net",
17+
license="MIT",
18+
classifiers=[
19+
"License :: OSI Approved :: MIT License",
20+
"Programming Language :: Python :: 3",
21+
"Programming Language :: Python :: 3.7",
22+
],
23+
packages=["visa_cli"],
24+
include_package_data=True,
25+
entry_points={"console_scripts": ["visa-cli = visa_cli.__init__:main"]},
26+
install_requires=["art", "prompt-toolkit", "requests"],
27+
keywords=["awesome list", "awesome", "resources", "lists", "mammoths"],
28+
)

visa_cli/__init__.py

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
from .visa_status import Visa_Status
2+
import pandas as pd
3+
import argparse
4+
import sys
5+
6+
pd.set_option("display.max_rows", None)
7+
8+
9+
__version__ = "0.0.1"
10+
11+
12+
def main(argv=None):
13+
argv = sys.argv if argv is None else argv
14+
parser = argparse.ArgumentParser()
15+
parser.add_argument(
16+
"resident_country", type=str, help="Current Resident Country",
17+
)
18+
19+
parser.add_argument(
20+
"-f",
21+
"--visa-free",
22+
help="Countries not requiring Visa",
23+
dest="visa_free",
24+
action="store_true",
25+
)
26+
27+
parser.add_argument(
28+
"-r",
29+
"--visa-required",
30+
help="Countries requiring Visa",
31+
dest="visa_required",
32+
action="store_true",
33+
)
34+
35+
parser.add_argument(
36+
"-o",
37+
"--visa-on-arrival",
38+
help="Countries offering Visa on arrival",
39+
dest="visa_voa",
40+
action="store_true",
41+
)
42+
43+
parser.add_argument(
44+
"-e",
45+
"--eta",
46+
help="Countries offering Electronic Travel Authority",
47+
dest="visa_eta",
48+
action="store_true",
49+
)
50+
51+
parser.add_argument(
52+
"-n",
53+
"--visa-free-days",
54+
help="Countries offering Visa free days",
55+
dest="visa_free_days",
56+
action="store_true",
57+
)
58+
59+
parser.add_argument(
60+
"-c",
61+
"--covid-ban",
62+
help="Countries not offering Visa due to Covid-19",
63+
dest="visa_covid_ban",
64+
action="store_true",
65+
)
66+
67+
parser.add_argument(
68+
"-i",
69+
"--interactive",
70+
help="Interactive Prompt",
71+
dest="interactive_prompt",
72+
action="store_true",
73+
)
74+
args = parser.parse_args()
75+
76+
# https://raw.githubusercontent.com/ilyankou/passport-index-dataset/master/passport-index-matrix.csv
77+
current_residency = Visa_Status(
78+
"https://raw.githubusercontent.com/ilyankou/passport-index-dataset/master/passport-index-matrix.csv",
79+
args.resident_country,
80+
)
81+
82+
if args.visa_free:
83+
print(current_residency.get_status_vf())
84+
85+
if args.visa_required:
86+
print(current_residency.get_status_vr())
87+
88+
if args.visa_voa:
89+
print(current_residency.get_status_voa())
90+
91+
if args.visa_eta:
92+
print(current_residency.get_status_eta())
93+
94+
if args.visa_free_days:
95+
print(current_residency.get_status_vfe())
96+
97+
if args.visa_covid_ban:
98+
print(current_residency.get_covid_ban())
99+
100+
if args.interactive_prompt:
101+
current_residency.interactive_prompt()

visa_cli/visa_status.py

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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

Comments
 (0)