A CLI tool for geographical location utilities.
Project description
Geoloc
CLI Project Name: geoloc
Description
Based on the user input, city and state or zip, make an api all to get latitude, longitude, country, city, state...etc. Input can be a list of strings like below:
Possible examples:
● geoloc-util --locations “Madison, WI” “12345”
● geoloc-util “Madison, WI” “12345” “Chicago, IL” “10001
geoloc-util "01801" "Lincoln, IN" "000" "Kovai, IN" "11111" "13214654" "adf, ad" "a,a", "", " ", " , "
For the above input, the cli response is given below.
Zip: 01801
Country: US
State: Woburn
Latitude: 42.4829
Longitude: -71.1574
----------------------------------------
City: Lincoln
Country: US
State: Indiana
Latitude: 40.6155947
Longitude: -86.2099948
----------------------------------------
000:Incorrect Zip code
----------------------------------------
Kovai, IN:Non existent data given, please check if the State and City are correct Kovai and IN
----------------------------------------
11111:Non existent data given, please check if the zip code is correct 11111
----------------------------------------
13214654:Incorrect Zip code
Table of Contents
Prerequisites
- Python Version: This project requires Python 3.11 or higher.
- Package Manager: Ensure you have
pipinstalled, which comes with Python.
Installing Python
- For macOS:
- You can install Python using Homebrew. Open a terminal and run:
brew install python
- You can install Python using Homebrew. Open a terminal and run:
https://docs.brew.sh/Homebrew-and-Python Visit the above link to get exact steps on installing python 3.11
Installation
-
Create a Virtual Environment: It is recommended to create a virtual environment to manage dependencies. Run the following commands:
# Navigate to your project directory cd /path/to/your/project # Create a virtual environment python3 -m venv venv # On macOS/Linux source venv/bin/activate https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html
-
Install Poetry: Once pip is installed, then run pip install poetry to from within the virtual environment From pycharm terminal, run the command 'poetry --version' to see the Poetry version It's important the poetry is installed as it would take care of all the necessary dependencies for this project
-
Poetry build: Now run the command 'pip list' to see if any dependencies are installed by default Next run the command 'poetry build' and this would take a few minutes for the very first time to install all the dependencies listed in the pyproject.toml file Once again run 'pip list' command to see if bunch of additional libraries are installed like:
- pydantic
- pytest
- requests
- typing_extensions
These are just a few to list, depending on what other libraries are installed by default you might see additional 8-10 more
Usage
pip install geoloc-util this should install the geoloc-util to the machine and run the below command to see the output in the console.
geoloc-util --locations "Boston, MA"
Running tests:
This repository is built with pytest and the packages are managed with poetry. Once the necessary dependencies are installed you can run the tests either by selecting each tests in the test class or run them as a suite by below command.
(venv) <machine-name>:geoloc swami.padmanabhan$
Make sure to navigate to the geoloc folder in your local machine
pytest -v -s tests/test_geo_loc.py
after running this command, the logs will be created in the Projects/geoloc/logs [check in the main root foler]
If running the tests, individually from the test class, then the logs will be created within the tests folder
Features
- Reusability: Build with multiple design principles in mind, like reusability to having methods that makes api calls for various endpoints.
- Logs: source logs separate from test logs, however logger functionality is maintained at a common place
- Readability: Logs are easily readable and the methods and classes follow the same
- Pydantic: To validate the json response for field input and type is implemented for both city and zip code response Mock Integration: Verifying the integration of the cli by creating mock response and checking for validity
Contribution
Fully written and developed by Swami Padmanabhan
License
MIT license is used
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file geoloc-0.1.1.tar.gz.
File metadata
- Download URL: geoloc-0.1.1.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a1344fcbd992db7a2e792a42e93892ee1c68cdea0faf7fb391d079c9f207fa6
|
|
| MD5 |
5efc0a570c5e69ca44735ff4f7edb9e6
|
|
| BLAKE2b-256 |
f6751dfd69f8f7503491d9008ed8aa40864e7dcb278bd22794a1b5d3df6771e8
|
File details
Details for the file geoloc-0.1.1-py3-none-any.whl.
File metadata
- Download URL: geoloc-0.1.1-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83f6115482689135a4a62ae40642afb44a94b97e5031e6c580c62134972cd50c
|
|
| MD5 |
9a89a3cba6a11ec16e55b72fdd25a2f3
|
|
| BLAKE2b-256 |
6842f7a0e63bedb135a8afb32c1696153d37c4c73212279f718c7d634402c976
|