Skip to main content

A python package that lists regions, provinces, and cities/municipalities in the Philippines

Project description

phgeograpy (PH Geography)
===

phgeograpy is a python package that lists regions, provinces, and cities/municipalities in the Philippines.

Take a break from machine learning and chatbots. I created this project to explore and experience building a python package. This is my first python package. Yey! I'll also use this project to expore unit testing.

I'm working on a web app that needs location input broken down into regions, provinces, and cities/municipalities so I created this package to make it reusable and open source. Technically it's just a list, you can use it to create dropdown inputs or model choices in Django.

# Regions

Regions are represented by `phgeograpy.Region` class.

Sample usage:

```python
import phgeograpy

# Get all regions in the philippines
regions = phgeograpy.regions()

# Get the details of the first region
print(regions[0].slug) # A unique id of the region
print(regions[0].name) # Name of the region
print(regions[0].description) # A longer/alternative name of the region

# Get a specific region.
# If no region is found, an Exception will be raised.
region = phgeograpy.regions('ncr') # `ncr` is the slug of NCR.
```

# Provinces

Provinces are represented by `phgeograpy.Province` class.

Sample usage:

```python
import phgeograpy

# Get all provinces in the philippines
provinces = phgeograpy.provinces()

# Get the details of the first province
print(provinces[0].slug) # A unique id of the province
print(provinces[0].name)

# Get the region where the province is located
region = provinces[0].region

# Get provinces of a specific region
region1_provinces = phgeograpy.provinces(region_slug='region1')

# You can also get the provinces from the `phgeograpy.Region` class instance
region1 = phgeograpy.regions('region1')
region1_provinces = region1.provinces()
```

# Municipalities

Municipalities are represented by `phgeograpy.Municipality` class. Cities are also included.

Sample Usage:

```python
import phgeograpy

# Get all municipalities in the philippines
municipalities = phgeograpy.municipalities()

# Get the details of the first municipality
print(municipalities[0].slug) # A unique id of the municipality
print(municipalities[0].name)
print(municipalities[0].is_city) # `True` if the instance is a city
print(municipalities[0].is_capital) # `True` if the instance is the capital of the province it is located
print(municipalities[0].is_huc) # `True` if the instance is a highly-urbanized/independent city

# Get the province where the municipality is located
province = municipalities[0].province

# Get municipalities from the `phgeograpy.Province` class instance
municipalities = province.municipalities()
```

# Raw data

To get raw data, just set `raw` parameter to `True`.

Sample usage:

```python
# Get raw regions data
raw_regions = phgeograpy.regions(raw=True)
```

Note that all data below the area of your query will be included in the raw output (e.g. raw regions will include data for provinces and municipalities, raw provinces will include data for municipalities).


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

phgeograpy-1.0.0.tar.gz (30.2 kB view details)

Uploaded Source

Built Distribution

phgeograpy-1.0.0-py2.py3-none-any.whl (36.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file phgeograpy-1.0.0.tar.gz.

File metadata

  • Download URL: phgeograpy-1.0.0.tar.gz
  • Upload date:
  • Size: 30.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for phgeograpy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 65ee9e448a40ea595830564153a2cd588e98c2f505aa50bcdbb798c91649dcbd
MD5 3d22ef5bb309c154786084eeb05f2bda
BLAKE2b-256 113a1c24218188f097a801694b098efbcd9c5c6176ed3fb42e13c275ceb085b5

See more details on using hashes here.

File details

Details for the file phgeograpy-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for phgeograpy-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 88c8079dd2a29df57dc3388d743367b05911bbd65fb1b58efa6009777075dd07
MD5 0d6647bcb3f902999b717e5c332d19fe
BLAKE2b-256 6590f1839f28fd95b6d9b842ffeaa31694523385d1419057a06a11ca1e988ade

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page