-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
70 changed files
with
7,979 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: 31dd932cca36007dd750fe41a9f6f829 | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
API Reference | ||
============= | ||
|
||
This section provides a detailed overview of the available methods and their usage in **pyworldatlas**. Each method is designed to retrieve specific data about countries, with simple and intuitive interfaces. | ||
|
||
.. note:: | ||
Throughout the examples, we will assume **pyworldatlas** has been imported as `pwa`. | ||
|
||
.. code-block:: python | ||
import pyworldatlas as pwa | ||
atlas = pwa.Atlas() | ||
Classes and Methods | ||
------------------- | ||
|
||
Atlas Class | ||
----------- | ||
The **Atlas** class is the main interface for accessing country data. It provides several methods to retrieve specific country profiles, lists of countries, and other data. | ||
|
||
get_country_profile | ||
------------------- | ||
Fetches detailed profile information for a specific country. | ||
|
||
**Parameters**: | ||
- **name** (*str*) – The name or ISO 3166 Alpha-2 code of the country. | ||
|
||
**Returns**: | ||
- **dict** – A dictionary containing detailed information about the country's official names, capital, largest city, area, population, government, and more. | ||
|
||
**Example**: | ||
|
||
.. code-block:: python | ||
profile = atlas.get_country_profile("France") | ||
print(profile) | ||
**Example Output**: | ||
|
||
.. code-block:: python | ||
{ | ||
'capital': { | ||
'name': 'Paris', | ||
'coordinates_degree_east': 2.3522, | ||
'coordinates_degree_north': 48.8566, | ||
'is_largest_city': True, | ||
}, | ||
'driving_side': 'Right', | ||
'calling_code': '+33', | ||
'iso_3166_code': 'FR', | ||
'internet_tld': '.fr', | ||
} | ||
get_countries (WIP) | ||
------------------- | ||
Fetches a list of countries, optionally filtered by continents or population/GDP ranges. | ||
|
||
**Parameters:** | ||
|
||
- **continents** (*list of str, optional*) – The continents to filter by (e.g., ``["Asia", "Europe"]``). | ||
- **min_population** (*float, optional*) – The minimum population to filter by. | ||
- **max_population** (*float, optional*) – The maximum population to filter by. | ||
- **min_gdp** (*float, optional*) – The minimum GDP to filter by. | ||
- **max_gdp** (*float, optional*) – The maximum GDP to filter by. | ||
|
||
**Returns**: | ||
|
||
- **list of str** – A list of country names that match the criteria. | ||
|
||
**Example**: | ||
|
||
.. code-block:: python | ||
countries = atlas.get_countries(continents=["Europe"], min_population=1000000) | ||
print(countries) | ||
**Example Output**: | ||
|
||
.. code-block:: python | ||
['France', 'Germany', 'Italy', 'Spain'] | ||
get_progress | ||
------------ | ||
Returns the percentage of data that the package currently contains. | ||
|
||
**Returns**: | ||
- **float** – The percentage of the dataset that is complete. | ||
|
||
**Example**: | ||
|
||
.. code-block:: python | ||
progress = atlas.get_progress() | ||
**Example Output**: | ||
|
||
.. code-block:: python | ||
"Current data size: 3, Total data size: 285, Progress: 1.1%" | ||
Error Handling | ||
-------------- | ||
|
||
**pyworldatlas** provides custom exceptions to help identify and handle errors efficiently. | ||
|
||
CountryNotFoundError | ||
-------------------- | ||
Raised when a country is not found in the dataset. | ||
|
||
**Example**: | ||
|
||
.. code-block:: python | ||
try: | ||
profile = atlas.get_country_profile("Nonexistentland") | ||
except pwa.Atlas.CountryNotFoundError: | ||
print("Country not found.") | ||
Additional Features | ||
------------------- | ||
**pyworldatlas** is continually evolving. Refer to the `Roadmap <roadmap.html>`_ for upcoming features and improvements. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
Changelog | ||
========= | ||
|
||
0.0.7 - 2024-08-24 | ||
------------------ | ||
**Added** | ||
- Polished documentation, added database download and country data pages. | ||
- Finished the `get_country_profile` method, now it is a lot more refined and better. | ||
- Database is now shipped as a gzip and then decompressed for the package to use. | ||
- Added basic tests (need to be expanded). | ||
- Incorporated tox, to be able to test in different Python versions and tests behave accordingly. | ||
- Bumped the requirement for the package to Python 3.8+ (support for Python 3.7 or earlier is now deprecated). | ||
- Added the --version cli command for the package. | ||
- Methods are now fragmented to facilitate testing. | ||
- Many smaller other fixes and enhancements. | ||
- Databases are now de-fragmented prior to final release. | ||
|
||
0.0.6 - 2024-08-20 | ||
------------------ | ||
**Added** | ||
- Added Algeria country data. | ||
- Ensured uniqueness for languages in the dataset. | ||
|
||
0.0.5 - 2024-08-19 | ||
------------------ | ||
**Added** | ||
- Completed country data for Albania. | ||
- Added support for Daylight Savings Time (DST). | ||
|
||
**Fixed** | ||
- Updated largest city and coordinates for each country model. | ||
|
||
0.0.4 - 2024-08-19 | ||
------------------ | ||
**Added** | ||
- Introduced the `Continent` model following the 7-continent approach. | ||
- Added the `needs_updated` and `last_updated` fields to the country model. | ||
- Introduced office terms for prime ministers, presidents, and other leaders. | ||
|
||
0.0.3 - 2024-08-16 | ||
------------------ | ||
**Added** | ||
- Initial base model. | ||
- Added data for Afghanistan (0.35% completion). | ||
- Added official country names for stronger profiles (e.g., "Albania" -> "Republic of Albania"). | ||
- Added Wikipedia revision ID for each country to track data sources. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Contributing | ||
============ | ||
|
||
Thank you for your interest in contributing to **pyworldatlas**. | ||
|
||
At this time, **pyworldatlas** is a personal project, and I am not accepting any external contributions. The goal is to fully complete the package before opening it up to collaboration. | ||
|
||
Once the project reaches a stable and complete state, I will provide detailed guidelines for contributing, including coding standards, issue reporting, and feature requests. | ||
|
||
Stay tuned for updates! In the meantime, feel free to use the package and provide feedback via the `GitHub Issue Tracker <https://github.com/yourrepo/pyworldatlas/issues>`_. | ||
|
||
Thank you for your understanding! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Country Data | ||
============ | ||
|
||
This page lists all the countries currently available in the `pyworldatlas` database. If a country is shown below, it indicates that its information is present in the database. Otherwise, the country is yet to be added. | ||
|
||
.. list-table:: Countries in pyworldatlas Database | ||
:header-rows: 1 | ||
:widths: 20 10 | ||
|
||
* - **Country** | ||
- **ISO 3166 CODE** | ||
* - Afghanistan | ||
- AF | ||
* - Albania | ||
- AL | ||
* - Algeria | ||
- DZ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Database Download | ||
================= | ||
|
||
The `pyworldatlas` database is available for download. This database contains all the current information compiled about the countries in the package. | ||
|
||
.. note:: | ||
The database is included by default when you install `pyworldatlas`, so downloading it manually is optional unless you want to access it separately. | ||
|
||
Download Link | ||
------------- | ||
You can download the latest version of the database from the link below: | ||
|
||
- **Database File (Uncompressed)**: :download:`worldatlas.sqlite3 <worldatlas.sqlite3>` | ||
- **Database File (Compressed)**: :download:`worldatlas.sqlite3.gz <worldatlas.sqlite3.gz>` | ||
|
||
File Details | ||
------------ | ||
|
||
- **Uncompressed**: | ||
|
||
- **Size**: 288 KB | ||
- **SHA-256 Hash**: | ||
|
||
`2e8b9594da57e0e80f0a692530136dffb06d631375a159ea1bd242642d837760` | ||
|
||
|
||
- **Compressed (GZIP)**: | ||
|
||
- **Size**: 10 KB | ||
- **SHA-256 Hash**: | ||
|
||
`1fd820212aa6cbc3f07ab32c3a4db3b7f683c1101a80a7649ddcf2fdf0aa7bd0` | ||
|
||
|
||
|
||
Verifying the File | ||
------------------ | ||
To ensure the integrity of the downloaded database file, you can verify the SHA-256 hash. This can be done with the following command, depending on your operating system: | ||
|
||
**Linux/Mac**: | ||
|
||
.. code-block:: bash | ||
sha256sum worldatlas.sqlite3 | ||
**Windows (PowerShell)**: | ||
|
||
.. code-block:: powershell | ||
Get-FileHash worldatlas.sqlite3 -Algorithm SHA256 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Examples | ||
======== | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
FAQ | ||
=== | ||
|
||
Below are some frequently asked questions about **pyworldatlas**. If you have any additional questions, feel free to check the `GitHub Issue Tracker <https://github.com/yourrepo/pyworldatlas/issues>`_. | ||
|
||
Does pyworldatlas require an internet connection to work? | ||
--------------------------------------------------------- | ||
No, **pyworldatlas** ships with a built-in SQLite database called `worldatlas.sqlite3`, so all the data is stored locally. This ensures that you can use the package without needing an internet connection. | ||
|
||
How does pyworldatlas ensure political neutrality? | ||
-------------------------------------------------- | ||
The data compiled by **pyworldatlas** aims to be politically neutral. I rely on publicly available sources and focus on objective data like official country names, population, geography, and economic statistics. I avoid any subjective or political opinions. | ||
|
||
What is the minimum Python version required to use pyworldatlas? | ||
---------------------------------------------------------------- | ||
**pyworldatlas** requires Python 3.8 or higher to work properly. However, Python 3.9 is best for maximum performance. | ||
|
||
Does pyworldatlas depend on any external libraries? | ||
--------------------------------------------------- | ||
No, **pyworldatlas** does not have any external dependencies. It is designed to be lightweight, with everything handled internally using Python’s standard libraries, such as SQLite. | ||
|
||
What data can I get from pyworldatlas? | ||
-------------------------------------- | ||
**pyworldatlas** provides a wide range of data for each country, including official names, population, capital, largest city, GDP, government structure, and more. For a full list of available data, refer to the `API Reference <api_reference.html>`_. | ||
|
||
Where does pyworldatlas source its data from? | ||
--------------------------------------------- | ||
The data in **pyworldatlas** is manually compiled from publicly available resources, primarily sourced from the `List of Countries on Simple Wikipedia <https://simple.wikipedia.org/wiki/List_of_countries>`_. The goal is to ensure that the information provided is accurate and up to date. | ||
|
||
How can I verify the source of the data for each country? | ||
--------------------------------------------------------- | ||
Each country's profile in **pyworldatlas** includes the main Wikipedia article revision ID from which the information was sourced. This ensures transparency and allows users to verify the exact version of the data used. A method to quickly retrieve the revision ID will be available soon for convenience. | ||
|
||
How do I report an issue or suggest a feature? | ||
---------------------------------------------- | ||
If you encounter any issues or have suggestions for new features, please visit our `GitHub Issue Tracker <https://github.com/yourrepo/pyworldatlas/issues>`_ and create a new issue. Contributions are always welcome! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
Getting Started | ||
=============== | ||
|
||
This guide will help you get up and running with **pyworldatlas**. In just a few steps, you’ll be able to access comprehensive data about any country using simple method calls. | ||
|
||
Prerequisites | ||
------------- | ||
Before you begin, ensure you have installed **pyworldatlas**. If you haven’t already, check out the `Installation <installation.html>`_ guide. | ||
|
||
Basic Usage | ||
----------- | ||
Once installed, using pyworldatlas is straightforward. The package provides a simple interface to retrieve detailed information about countries. Below is an example to get you started. | ||
|
||
Example: Fetching a Country's Profile | ||
------------------------------------- | ||
To begin, import the package and create an instance of the **Atlas** class. Then, you can use the `get_country_profile` method to retrieve information about a specific country. | ||
|
||
Here's a basic example: | ||
|
||
.. code-block:: python | ||
import pyworldatlas as pwa | ||
atlas = pwa.Atlas() | ||
# Fetch the profile of a country by name | ||
profile = atlas.get_country_profile("United States") | ||
# Display the profile information | ||
print(profile) | ||
This will return a dictionary containing detailed information about the specified country, including its capital, largest city, driving side, and more. | ||
|
||
Example Output | ||
-------------- | ||
The output will look something like this: | ||
|
||
.. code-block:: python | ||
{ | ||
'capital': { | ||
'name': 'Washington, D.C.', | ||
'coordinates_degree_east': -77.0369, | ||
'coordinates_degree_north': 38.9072, | ||
'is_largest_city': False, | ||
}, | ||
'largest_city': { | ||
'name': 'New York City', | ||
'coordinates_degree_east': -74.0060, | ||
'coordinates_degree_north': 40.7128, | ||
}, | ||
'driving_side': 'Right', | ||
'calling_code': '+1', | ||
'iso_3166_code': 'US', | ||
'internet_tld': '.us', | ||
} | ||
What Next? | ||
---------- | ||
With this foundation, you can start exploring other features of **pyworldatlas**. Refer to the `API Reference <api_reference.html>`_ for a comprehensive list of available methods and options. |
Oops, something went wrong.