From 0d56dc15f485c10511abfeaf5e81f0ba55ce5390 Mon Sep 17 00:00:00 2001 From: mskian <10300271+mskian@users.noreply.github.com> Date: Wed, 28 Feb 2024 23:20:32 +0530 Subject: [PATCH] multiple updates : readme and add loading spinner --- README.md | 36 +++++++++++++++++++++++++++++++++--- requirements.txt | 3 ++- wt.py | 12 ++++++++++-- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a4dc5ad..0354e53 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,10 @@ Search the country name or timezone to get the current date and time. -WIP 🚧 - ## usage -- require Python 3 +- Require Python 3 +- Download and run it (it use JSON data as fallback database from external Source) ```sh @@ -20,6 +19,37 @@ python3 wt.py ``` +- install locally +- it uses the sqlite3 database from locally installed source + +```sh + +## Clone the Repo +git clone https://github.com/sanwebinfo/timezone.git +cd timezone + +## install Modules +python3 -m pip install -r requirements.txt + +or + +python -m pip install -r requirements.txt + +## Run the CLI +python wt.py + +or + +python3 wt.py + +``` + +## Database + +- all the timezone and country was stored in the folder `/database` +- `db`, `JSON`, and `CSV` data files +- Database build using sqlite3 and pytz and pycountry Module + ## LICENSE MIT diff --git a/requirements.txt b/requirements.txt index 8bd8f01..b1c3e13 100644 --- a/requirements.txt +++ b/requirements.txt @@ -110,7 +110,7 @@ six==1.14.0 soupsieve==2.4 spinners==0.0.24 systemd-python==234 -termcolor==2.2.0 +termcolor==2.4.0 toml==0.10.2 tomli==2.0.1 types-requests==2.25.1 @@ -128,4 +128,5 @@ websocket-client==1.6.3 Werkzeug==2.2.3 wrapt==1.11.2 xkit==0.0.0 +yaspin==2.5.0 zipp==3.15.0 diff --git a/wt.py b/wt.py index 9e7a4f6..d2f86cb 100755 --- a/wt.py +++ b/wt.py @@ -5,8 +5,12 @@ import importlib.util import pytz import requests +import time +from yaspin import yaspin -packages = ['pytz', 'requests'] +spinner = yaspin(text="Searching...", color="cyan") + +packages = ['pytz', 'requests', 'yaspin'] missing_packages = [package for package in packages if importlib.util.find_spec(package) is None] if missing_packages: @@ -106,7 +110,7 @@ def get_world_time(timezone): def main(): try: - country_timezones = load_country_timezones_from_db("/database/country.db") + country_timezones = load_country_timezones_from_db("./database/country.db") print("\n") while True: search_input = input("Enter a country or timezone to get the current time (or 'quit' to exit): ").strip() @@ -120,6 +124,10 @@ def main(): print("\n") continue + spinner.start() + time.sleep(3) + spinner.stop() + if '/' in search_input: timezones = [search_input] else: