atlas-world-intel 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- atlas_world_intel-1.0.0/LICENSE +21 -0
- atlas_world_intel-1.0.0/PKG-INFO +91 -0
- atlas_world_intel-1.0.0/README.md +64 -0
- atlas_world_intel-1.0.0/atlas/__init__.py +1 -0
- atlas_world_intel-1.0.0/atlas/commands/__init__.py +1 -0
- atlas_world_intel-1.0.0/atlas/commands/ask.py +31 -0
- atlas_world_intel-1.0.0/atlas/commands/compare.py +30 -0
- atlas_world_intel-1.0.0/atlas/commands/country.py +65 -0
- atlas_world_intel-1.0.0/atlas/commands/currency.py +39 -0
- atlas_world_intel-1.0.0/atlas/commands/learn.py +37 -0
- atlas_world_intel-1.0.0/atlas/commands/quiz.py +64 -0
- atlas_world_intel-1.0.0/atlas/commands/rankings.py +39 -0
- atlas_world_intel-1.0.0/atlas/commands/travel.py +32 -0
- atlas_world_intel-1.0.0/atlas/core/__init__.py +1 -0
- atlas_world_intel-1.0.0/atlas/core/api.py +292 -0
- atlas_world_intel-1.0.0/atlas/core/display.py +301 -0
- atlas_world_intel-1.0.0/atlas/core/utils.py +60 -0
- atlas_world_intel-1.0.0/atlas/data/country_fallback.json +122 -0
- atlas_world_intel-1.0.0/atlas/data/quiz_questions.json +39 -0
- atlas_world_intel-1.0.0/atlas/data/travel_info.json +38 -0
- atlas_world_intel-1.0.0/atlas/main.py +113 -0
- atlas_world_intel-1.0.0/atlas_world_intel.egg-info/PKG-INFO +91 -0
- atlas_world_intel-1.0.0/atlas_world_intel.egg-info/SOURCES.txt +28 -0
- atlas_world_intel-1.0.0/atlas_world_intel.egg-info/dependency_links.txt +1 -0
- atlas_world_intel-1.0.0/atlas_world_intel.egg-info/entry_points.txt +2 -0
- atlas_world_intel-1.0.0/atlas_world_intel.egg-info/requires.txt +10 -0
- atlas_world_intel-1.0.0/atlas_world_intel.egg-info/top_level.txt +1 -0
- atlas_world_intel-1.0.0/pyproject.toml +47 -0
- atlas_world_intel-1.0.0/setup.cfg +4 -0
- atlas_world_intel-1.0.0/tests/test_cli.py +30 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Khizar Arain
|
|
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.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: atlas-world-intel
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: World Intelligence CLI - explore countries, economies, currencies and geography from your terminal
|
|
5
|
+
Author-email: Khizar Arain <your@email.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://khizar-arain.vercel.app
|
|
8
|
+
Project-URL: Repository, https://github.com/khizerarain/atlas
|
|
9
|
+
Keywords: cli,world,geography,countries,terminal,atlas
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: typer[all]>=0.12.0
|
|
17
|
+
Requires-Dist: rich>=13.0.0
|
|
18
|
+
Requires-Dist: requests>=2.31.0
|
|
19
|
+
Requires-Dist: openai>=1.0.0
|
|
20
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
21
|
+
Requires-Dist: thefuzz>=0.22.0
|
|
22
|
+
Requires-Dist: pytz>=2024.1
|
|
23
|
+
Requires-Dist: pycountry>=23.12.11
|
|
24
|
+
Requires-Dist: geopy>=2.4.0
|
|
25
|
+
Requires-Dist: forex-python>=1.8
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# ATLAS
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install atlas-world-intel
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Then run:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
atlas
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
No cloning required.
|
|
43
|
+
|
|
44
|
+
ATLAS is a Python command-line experience for exploring the world from your terminal. It combines country data, rankings, currency conversion, travel tips, a geography quiz, and AI-powered explanations into a single polished dashboard.
|
|
45
|
+
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
> Animated demo placeholder β add a GIF named demo.gif to this folder to replace the placeholder.
|
|
49
|
+
|
|
50
|
+
## Development
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
git clone https://github.com/khizerarain/atlas
|
|
54
|
+
cd atlas
|
|
55
|
+
pip install -r requirements.txt
|
|
56
|
+
cp .env.example .env
|
|
57
|
+
# Add your API keys to .env
|
|
58
|
+
python -m atlas.main
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Commands
|
|
62
|
+
|
|
63
|
+
| Command | Example | Description |
|
|
64
|
+
| --- | --- | --- |
|
|
65
|
+
| atlas country | atlas country japan | Show a Rich country profile with key facts |
|
|
66
|
+
| atlas compare | atlas compare france germany | Compare two countries side by side |
|
|
67
|
+
| atlas top | atlas top population | Show the top 10 countries by population, area, or borders |
|
|
68
|
+
| atlas convert | atlas convert 100 USD PKR | Convert currencies using live exchange rates |
|
|
69
|
+
| atlas time | atlas time japan | Show the current local time for a country |
|
|
70
|
+
| atlas quiz | atlas quiz | Run a 10-question geography quiz |
|
|
71
|
+
| atlas learn | atlas learn africa | Show continent-level highlights |
|
|
72
|
+
| atlas ask | atlas ask What is the capital of Morocco? | Ask ATLAS AI a geography question |
|
|
73
|
+
| atlas travel | atlas travel japan | Show travel tips and emergency info |
|
|
74
|
+
|
|
75
|
+
## Tech Stack
|
|
76
|
+
|
|
77
|
+
- Python
|
|
78
|
+
- Typer
|
|
79
|
+
- Rich
|
|
80
|
+
- RestCountries API
|
|
81
|
+
- OpenAI
|
|
82
|
+
- exchangerate.host
|
|
83
|
+
|
|
84
|
+
## Environment Variables
|
|
85
|
+
|
|
86
|
+
- OPENAI_API_KEY: Required for AI answers via the atlas ask command.
|
|
87
|
+
- EXCHANGE_API_KEY: Optional for exchange-rate integrations; the default free endpoint is used when it is not present.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
[](https://choosealicense.com/licenses/mit/)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# ATLAS
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install atlas-world-intel
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Then run:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
atlas
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
No cloning required.
|
|
16
|
+
|
|
17
|
+
ATLAS is a Python command-line experience for exploring the world from your terminal. It combines country data, rankings, currency conversion, travel tips, a geography quiz, and AI-powered explanations into a single polished dashboard.
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
> Animated demo placeholder β add a GIF named demo.gif to this folder to replace the placeholder.
|
|
22
|
+
|
|
23
|
+
## Development
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
git clone https://github.com/khizerarain/atlas
|
|
27
|
+
cd atlas
|
|
28
|
+
pip install -r requirements.txt
|
|
29
|
+
cp .env.example .env
|
|
30
|
+
# Add your API keys to .env
|
|
31
|
+
python -m atlas.main
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Commands
|
|
35
|
+
|
|
36
|
+
| Command | Example | Description |
|
|
37
|
+
| --- | --- | --- |
|
|
38
|
+
| atlas country | atlas country japan | Show a Rich country profile with key facts |
|
|
39
|
+
| atlas compare | atlas compare france germany | Compare two countries side by side |
|
|
40
|
+
| atlas top | atlas top population | Show the top 10 countries by population, area, or borders |
|
|
41
|
+
| atlas convert | atlas convert 100 USD PKR | Convert currencies using live exchange rates |
|
|
42
|
+
| atlas time | atlas time japan | Show the current local time for a country |
|
|
43
|
+
| atlas quiz | atlas quiz | Run a 10-question geography quiz |
|
|
44
|
+
| atlas learn | atlas learn africa | Show continent-level highlights |
|
|
45
|
+
| atlas ask | atlas ask What is the capital of Morocco? | Ask ATLAS AI a geography question |
|
|
46
|
+
| atlas travel | atlas travel japan | Show travel tips and emergency info |
|
|
47
|
+
|
|
48
|
+
## Tech Stack
|
|
49
|
+
|
|
50
|
+
- Python
|
|
51
|
+
- Typer
|
|
52
|
+
- Rich
|
|
53
|
+
- RestCountries API
|
|
54
|
+
- OpenAI
|
|
55
|
+
- exchangerate.host
|
|
56
|
+
|
|
57
|
+
## Environment Variables
|
|
58
|
+
|
|
59
|
+
- OPENAI_API_KEY: Required for AI answers via the atlas ask command.
|
|
60
|
+
- EXCHANGE_API_KEY: Optional for exchange-rate integrations; the default free endpoint is used when it is not present.
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
[](https://choosealicense.com/licenses/mit/)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.0.0"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# commands package
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
import typer
|
|
6
|
+
|
|
7
|
+
from atlas.core.api import ask_ai, check_internet
|
|
8
|
+
from atlas.core.display import show_ai_answer, show_error, show_no_internet, show_warning
|
|
9
|
+
|
|
10
|
+
app = typer.Typer(help="Ask ATLAS AI")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@app.callback(invoke_without_command=True)
|
|
14
|
+
def ask_ai_command(question: str = typer.Argument(..., help="Question to ask ATLAS")) -> None:
|
|
15
|
+
if not question:
|
|
16
|
+
show_error("Please provide a question.")
|
|
17
|
+
raise typer.Exit(code=1)
|
|
18
|
+
|
|
19
|
+
if not os.getenv("OPENAI_API_KEY") or os.getenv("OPENAI_API_KEY") == "your_key_here":
|
|
20
|
+
show_warning("OpenAI API key is not configured. Add it to .env to enable AI answers.")
|
|
21
|
+
return
|
|
22
|
+
|
|
23
|
+
if not check_internet():
|
|
24
|
+
show_no_internet()
|
|
25
|
+
return
|
|
26
|
+
|
|
27
|
+
answer = ask_ai(question)
|
|
28
|
+
if answer:
|
|
29
|
+
show_ai_answer(answer)
|
|
30
|
+
else:
|
|
31
|
+
show_error("ATLAS AI could not answer that question right now.")
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
|
|
5
|
+
from atlas.core.api import check_internet, get_country
|
|
6
|
+
from atlas.core.display import show_comparison_table, show_error, show_no_internet
|
|
7
|
+
|
|
8
|
+
app = typer.Typer(help="Compare two countries")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@app.callback(invoke_without_command=True)
|
|
12
|
+
def compare_countries(
|
|
13
|
+
country_a: str = typer.Argument(..., help="First country"),
|
|
14
|
+
country_b: str = typer.Argument(..., help="Second country"),
|
|
15
|
+
) -> None:
|
|
16
|
+
if not country_a or not country_b:
|
|
17
|
+
show_error("Please provide two country names.")
|
|
18
|
+
raise typer.Exit(code=1)
|
|
19
|
+
|
|
20
|
+
if not check_internet():
|
|
21
|
+
show_no_internet()
|
|
22
|
+
return
|
|
23
|
+
|
|
24
|
+
a = get_country(country_a)
|
|
25
|
+
b = get_country(country_b)
|
|
26
|
+
if not a or not b:
|
|
27
|
+
show_error("One or both countries could not be found.")
|
|
28
|
+
return
|
|
29
|
+
|
|
30
|
+
show_comparison_table(a, b)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
from rich.prompt import Prompt
|
|
5
|
+
|
|
6
|
+
from atlas.core.api import check_internet, get_country, search_countries
|
|
7
|
+
from atlas.core.display import show_country_card, show_error, show_loading, show_no_internet, show_suggestions
|
|
8
|
+
|
|
9
|
+
app = typer.Typer(help="Look up country details")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@app.callback(invoke_without_command=True)
|
|
13
|
+
def country_lookup(name: str = typer.Argument(..., help="Country name")) -> None:
|
|
14
|
+
if not name:
|
|
15
|
+
show_error("Please provide a country name.")
|
|
16
|
+
raise typer.Exit(code=1)
|
|
17
|
+
|
|
18
|
+
if not check_internet():
|
|
19
|
+
show_no_internet()
|
|
20
|
+
return
|
|
21
|
+
|
|
22
|
+
with show_loading(f"Looking up {name}..."):
|
|
23
|
+
data = get_country(name)
|
|
24
|
+
|
|
25
|
+
if not data:
|
|
26
|
+
suggestions = [c["name"] for c in search_countries(name, limit=3)]
|
|
27
|
+
show_suggestions(name, suggestions)
|
|
28
|
+
return
|
|
29
|
+
|
|
30
|
+
show_country_card(data)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@app.command("clock")
|
|
34
|
+
def show_world_clock_command(country_name: str) -> None:
|
|
35
|
+
if not check_internet():
|
|
36
|
+
show_no_internet()
|
|
37
|
+
return
|
|
38
|
+
|
|
39
|
+
data = get_country(country_name)
|
|
40
|
+
if not data:
|
|
41
|
+
show_error(f"Country '{country_name}' was not found.")
|
|
42
|
+
return
|
|
43
|
+
|
|
44
|
+
from datetime import datetime
|
|
45
|
+
from zoneinfo import ZoneInfo
|
|
46
|
+
|
|
47
|
+
tz_name = None
|
|
48
|
+
for candidate in data.get("timezones") or []:
|
|
49
|
+
try:
|
|
50
|
+
tz_name = candidate
|
|
51
|
+
ZoneInfo(candidate)
|
|
52
|
+
break
|
|
53
|
+
except Exception:
|
|
54
|
+
continue
|
|
55
|
+
|
|
56
|
+
if not tz_name:
|
|
57
|
+
show_error("No timezone data available for that country.")
|
|
58
|
+
return
|
|
59
|
+
|
|
60
|
+
now = datetime.now(ZoneInfo(tz_name))
|
|
61
|
+
offset = now.strftime("%z")
|
|
62
|
+
offset_text = f"UTC{offset[:3]}:{offset[3:]}"
|
|
63
|
+
from atlas.core.display import show_world_clock
|
|
64
|
+
|
|
65
|
+
show_world_clock(f"{data.get('capital', 'N/A')}, {data.get('name', 'N/A')}", now.strftime("%Y-%m-%d %H:%M:%S"), offset_text)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
|
|
5
|
+
from atlas.core.api import check_internet, convert_currency
|
|
6
|
+
from atlas.core.display import show_conversion, show_error, show_no_internet
|
|
7
|
+
|
|
8
|
+
app = typer.Typer(help="Convert currencies")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@app.callback(invoke_without_command=True)
|
|
12
|
+
def convert_currency_command(
|
|
13
|
+
amount: float = typer.Argument(..., help="Amount to convert"),
|
|
14
|
+
from_code: str = typer.Argument(..., help="Source currency code"),
|
|
15
|
+
to_code: str = typer.Argument(..., help="Destination currency code"),
|
|
16
|
+
) -> None:
|
|
17
|
+
if amount <= 0:
|
|
18
|
+
show_error("Amount must be greater than zero.")
|
|
19
|
+
raise typer.Exit(code=1)
|
|
20
|
+
|
|
21
|
+
if not check_internet():
|
|
22
|
+
show_no_internet()
|
|
23
|
+
return
|
|
24
|
+
|
|
25
|
+
result = convert_currency(amount, from_code, to_code)
|
|
26
|
+
if not result:
|
|
27
|
+
show_error(
|
|
28
|
+
f"Unable to convert {from_code} to {to_code}. Try valid codes such as USD, EUR, GBP, JPY, PKR."
|
|
29
|
+
)
|
|
30
|
+
return
|
|
31
|
+
|
|
32
|
+
show_conversion(
|
|
33
|
+
result["amount"],
|
|
34
|
+
result["from"],
|
|
35
|
+
result["to"],
|
|
36
|
+
result["result"],
|
|
37
|
+
rate=result.get("rate"),
|
|
38
|
+
date=result.get("date"),
|
|
39
|
+
)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
|
|
5
|
+
from atlas.core.api import check_internet, get_all_countries
|
|
6
|
+
from atlas.core.display import show_error, show_learn_panel, show_no_internet
|
|
7
|
+
|
|
8
|
+
app = typer.Typer(help="Learn continent summaries")
|
|
9
|
+
|
|
10
|
+
VALID_CONTINENTS = {
|
|
11
|
+
"africa": "Africa",
|
|
12
|
+
"asia": "Asia",
|
|
13
|
+
"europe": "Europe",
|
|
14
|
+
"americas": "Americas",
|
|
15
|
+
"oceania": "Oceania",
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@app.callback(invoke_without_command=True)
|
|
20
|
+
def show_continent_summary(continent: str = typer.Argument(..., help="Continent name")) -> None:
|
|
21
|
+
normalized = continent.strip().lower()
|
|
22
|
+
if normalized not in VALID_CONTINENTS:
|
|
23
|
+
show_error("Continent must be one of: Africa, Asia, Europe, Americas, Oceania")
|
|
24
|
+
raise typer.Exit(code=1)
|
|
25
|
+
|
|
26
|
+
if not check_internet():
|
|
27
|
+
show_no_internet()
|
|
28
|
+
return
|
|
29
|
+
|
|
30
|
+
countries = [c for c in get_all_countries() if c.get("continent", "").lower() == VALID_CONTINENTS[normalized].lower()]
|
|
31
|
+
if not countries:
|
|
32
|
+
show_error("No country data available for that continent.")
|
|
33
|
+
return
|
|
34
|
+
|
|
35
|
+
largest = max(countries, key=lambda c: c.get("area_km2") or 0)
|
|
36
|
+
most_populous = max(countries, key=lambda c: c.get("population") or 0)
|
|
37
|
+
show_learn_panel(VALID_CONTINENTS[normalized], len(countries), largest, most_populous)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import random
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import typer
|
|
8
|
+
from rich.table import Table
|
|
9
|
+
|
|
10
|
+
from atlas.core.display import show_error, show_loading, show_success
|
|
11
|
+
|
|
12
|
+
app = typer.Typer(help="Take a geography quiz")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _load_questions() -> list[dict]:
|
|
16
|
+
data_path = Path(__file__).resolve().parent.parent / "data" / "quiz_questions.json"
|
|
17
|
+
with data_path.open("r", encoding="utf-8") as handle:
|
|
18
|
+
return json.load(handle)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@app.callback(invoke_without_command=True)
|
|
22
|
+
def run_quiz() -> None:
|
|
23
|
+
questions = _load_questions()
|
|
24
|
+
if len(questions) < 10:
|
|
25
|
+
show_error("Not enough quiz questions available.")
|
|
26
|
+
return
|
|
27
|
+
|
|
28
|
+
random.shuffle(questions)
|
|
29
|
+
selected = questions[:10]
|
|
30
|
+
score = 0
|
|
31
|
+
results = []
|
|
32
|
+
|
|
33
|
+
for idx, item in enumerate(selected, start=1):
|
|
34
|
+
with show_loading(f"Question {idx}/10"):
|
|
35
|
+
pass
|
|
36
|
+
answer = typer.prompt(f"{idx}. {item['question']}")
|
|
37
|
+
if str(answer).strip().lower() == str(item["answer"]).strip().lower():
|
|
38
|
+
score += 1
|
|
39
|
+
results.append((item["question"], answer, item["answer"], "β"))
|
|
40
|
+
else:
|
|
41
|
+
results.append((item["question"], answer, item["answer"], "β"))
|
|
42
|
+
|
|
43
|
+
if score == 10:
|
|
44
|
+
rating = "π World Expert"
|
|
45
|
+
elif score >= 7:
|
|
46
|
+
rating = "βοΈ Seasoned Traveler"
|
|
47
|
+
elif score >= 4:
|
|
48
|
+
rating = "πΊοΈ Explorer"
|
|
49
|
+
else:
|
|
50
|
+
rating = "π Keep Studying"
|
|
51
|
+
|
|
52
|
+
table = Table(title=f"Quiz Score: {score}/10 β {rating}", border_style="cyan", header_style="bold cyan")
|
|
53
|
+
table.add_column("#", justify="right")
|
|
54
|
+
table.add_column("Question")
|
|
55
|
+
table.add_column("Your Answer")
|
|
56
|
+
table.add_column("Correct Answer")
|
|
57
|
+
table.add_column("Result")
|
|
58
|
+
for i, (question, your_answer, correct_answer, result) in enumerate(results, start=1):
|
|
59
|
+
table.add_row(str(i), question, your_answer, correct_answer, result)
|
|
60
|
+
|
|
61
|
+
from rich.console import Console
|
|
62
|
+
|
|
63
|
+
Console().print(table)
|
|
64
|
+
show_success(f"You scored {score}/10 β {rating}")
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
|
|
5
|
+
from atlas.core.api import check_internet, get_all_countries
|
|
6
|
+
from atlas.core.display import show_error, show_no_internet, show_rankings_table
|
|
7
|
+
|
|
8
|
+
app = typer.Typer(help="Show top rankings")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@app.callback(invoke_without_command=True)
|
|
12
|
+
def show_rankings(metric: str = typer.Argument("population", help="Metric to rank by")) -> None:
|
|
13
|
+
if metric not in {"population", "area", "borders"}:
|
|
14
|
+
show_error("Metric must be one of: population, area, borders")
|
|
15
|
+
raise typer.Exit(code=1)
|
|
16
|
+
|
|
17
|
+
if not check_internet():
|
|
18
|
+
show_no_internet()
|
|
19
|
+
return
|
|
20
|
+
|
|
21
|
+
countries = get_all_countries()
|
|
22
|
+
if not countries:
|
|
23
|
+
show_error("No country data available right now.")
|
|
24
|
+
return
|
|
25
|
+
|
|
26
|
+
if metric == "population":
|
|
27
|
+
ranked = sorted(countries, key=lambda c: (c.get("population") or 0), reverse=True)[:10]
|
|
28
|
+
rows = [(i + 1, c.get("flag_emoji", ""), c.get("name", "N/A"), f"{int(c.get('population') or 0):,}") for i, c in enumerate(ranked)]
|
|
29
|
+
title = "π Top 10 by Population"
|
|
30
|
+
elif metric == "area":
|
|
31
|
+
ranked = sorted(countries, key=lambda c: (c.get("area_km2") or 0), reverse=True)[:10]
|
|
32
|
+
rows = [(i + 1, c.get("flag_emoji", ""), c.get("name", "N/A"), f"{int(c.get('area_km2') or 0):,} kmΒ²") for i, c in enumerate(ranked)]
|
|
33
|
+
title = "π Top 10 by Area"
|
|
34
|
+
else:
|
|
35
|
+
ranked = sorted(countries, key=lambda c: len(c.get("borders") or []), reverse=True)[:10]
|
|
36
|
+
rows = [(i + 1, c.get("flag_emoji", ""), c.get("name", "N/A"), str(len(c.get("borders") or []))) for i, c in enumerate(ranked)]
|
|
37
|
+
title = "π Top 10 by Borders"
|
|
38
|
+
|
|
39
|
+
show_rankings_table(title, rows)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
import typer
|
|
7
|
+
|
|
8
|
+
from atlas.core.display import show_error
|
|
9
|
+
|
|
10
|
+
app = typer.Typer(help="Travel tips and info")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@app.callback(invoke_without_command=True)
|
|
14
|
+
def travel_info(country: str = typer.Argument(..., help="Country name")) -> None:
|
|
15
|
+
if not country:
|
|
16
|
+
show_error("Please provide a country name.")
|
|
17
|
+
raise typer.Exit(code=1)
|
|
18
|
+
|
|
19
|
+
data_path = Path(__file__).resolve().parent.parent / "data" / "travel_info.json"
|
|
20
|
+
with data_path.open("r", encoding="utf-8") as handle:
|
|
21
|
+
content = json.load(handle)
|
|
22
|
+
|
|
23
|
+
match = content.get(country.lower())
|
|
24
|
+
if not match:
|
|
25
|
+
show_error("Travel info is not available for that country yet.")
|
|
26
|
+
return
|
|
27
|
+
|
|
28
|
+
from rich.console import Console
|
|
29
|
+
from rich.panel import Panel
|
|
30
|
+
|
|
31
|
+
lines = [f"Visa: {match.get('visa', 'N/A')}", f"Emergency: {match.get('emergency_numbers', 'N/A')}", f"Best months: {match.get('best_months', 'N/A')}", f"Weather: {match.get('weather_overview', 'N/A')}"]
|
|
32
|
+
Console().print(Panel("\n".join(lines), title=f"βοΈ Travel tips for {country.title()}", border_style="cyan"))
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# core package
|