CityofSantaMonica / mds-provider

Python tools for working with MDS Provider data

Home Page:https://github.com/openmobilityfoundation/mobility-data-specification

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mds-provider

Tools for working with MDS provider data.

Developed and tested with Python 3.7+.

See mds-provider-services for real-world usage of many of these tools.

Installation

Install with pip:

pip install -e git+https://github.com/CityofSantaMonica/mds-provider@master#egg=mds-provider

Or with python directly:

git clone https://github.com/CityofSantaMonica/mds-provider.git
cd mds-provider
python setup.py install

Getting Started

Read from a Provider API

from datetime import datetime, timedelta

import mds

end = datetime.utcnow()
start = end - timedelta(hours=1)

client = mds.Client("provider_name", token="secret-token")

trips = client.get_trips(start_time=start, end_time=end)

Validate against the MDS schema

validator = mds.DataValidator.trips()

for error in validator.validate(trips):
    print(error)

Load into a Postgres database

db = mds.Database(user="user", password="password", host="host", db="database")

db.load_trips(trips)

Package organization

module description
mds Tools for working with Mobility Data Specification provider data
mds.api Request data from compatible API endpoints
mds.db Work with databases
mds.encoding Custom data encoding and decoding.
mds.fake Generate fake provider data for testing and development
mds.files Work with provider configuration and data payload files
mds.geometry Helpers for GeoJSON-based geometry objects
mds.github Data and helpers for MDS on GitHub.
mds.providers Parse Provider registry files
mds.schemas Validate data using the JSON schemas
mds.versions Work with MDS versions

About

Python tools for working with MDS Provider data

https://github.com/openmobilityfoundation/mobility-data-specification

License:MIT License


Languages

Language:Python 100.0%