Merge pull request #18 from athuler/0.2.0

0.2.0
This commit is contained in:
Andrei Thüler authored and GitHub committed 2024-07-31 18:00:05 +02:00
commit e0f5e5d433
11 files changed
+1337 -374

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
# This workflow runs pytest on various Python versions when there is a push
name: Testing Package
on: push
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Test with pytest
run: |
pip install pytest pytest-cov
pytest
+2
View File
@@ -1,3 +1,5 @@
/passiogo/__pycache__
/tests/__pycache__
/.ipynb_checkpoints
Testing.ipynb
+23
View File
@@ -1,23 +1,44 @@
# Changelog
## 0.2.0 (2024-07-31)
### Added
- `TransportationSystem` class with the following methods: `getRoutes()`, `getStops()`, `getSystemAlerts()`
- `Route` class with the following method: `getStops()`
- `Stop` class
- `getSystems()`
- `getSystemsFromID()`
- `printAllSystemsMd()`
### Changed
### Removed
## 0.1.2 (2024-07-14)
### Added
- Added License
### Changed
- Fixed Documentation Build
- All
- Fixed PyPi long description type
- `printAllSystemsMd()` has the new parameter `includeHtml` with a default of `True` to render HTML breaks after each line
### Removed
- Removed obsolete `debug` parameters
## 0.1.1 (2024-07-12)
### Added
- Create Documentation With ReadTheDocs.io
- Create Changelog
- New `getSystems()` Method
@@ -25,9 +46,11 @@
- Added PyPi Project Links
### Changed
- Change Project Description
### Removed
- None
+352 -207
View File
@@ -1,9 +1,12 @@
# Passio Go API
[![PyPI - Version](https://img.shields.io/pypi/v/passiogo?label=Latest%20Version&link=https%3A%2F%2Fpypi.org%2Fproject%2FPassioGo%2F)](https://pypi.org/project/PassioGo/)
[![Pepy Total Downlods](https://img.shields.io/pepy/dt/PassioGo)](https://www.pepy.tech/projects/passiogo)
[![Documentation Status](https://readthedocs.org/projects/passiogo/badge/?version=latest)](https://passiogo.readthedocs.io/en/latest/?badge=latest)
An **unofficial** Python API for [Passio Go](https://passiogo.com/) allowing anyone to build transit-based applications for hundreds of Universities, Municipalities, Paratransit, and Airports.
@@ -27,6 +30,146 @@ mkdocs serve
```
## Usage
### Transportation System
Before doing anything, you will need a [`TransportationSystem`](api/#transportationsystem) object.
If you know the `id` of the desired transportation system, you can obtain the object using `passiogo.getSystemFromID(id)`.
```python
system = passiogo.getSystemFromID(1068)
```
If you do not know the ID of your desired transportation system, you can find it [here](#all-transportation-systems-accessible-by-the-api) or with the following:
```python
system = passiogo.printAllSystemsMd()
```
```md
- 3630 Peachtree (#951)<br/>
- 5025 Apartments (#1634)<br/>
- 725 Ponce (#1832)<br/>
- Agnes Scott College (#1471)<br/>
...
```
### Routes
You can obtain all the routes for a given transportation system using `TransportationSystem.getRoutes()`:
```python
routes = system.getRoutes()
```
Here, `routes` is a list of [`Route`](api/#route) objects. We can look at how much information is available for each route.
```python
routes[0].__dict__
```
```
{'id': '133007',
'groupId': '5702',
'groupColor': '#0000ff',
'name': 'Apostolic',
'shortName': 'AP',
'nameOrig': 'Apostolic',
'fullname': 'University of Chicago',
'myid': '38729',
'mapApp': '1',
'archive': '0',
'goPrefixRouteName': '1',
'goShowSchedule': 1,
'outdated': '0',
'distance': 578,
'latitude': '41.780867018',
'longitude': '-87.592902254',
'serviceTime': None,
'serviceTimeShort': None,
'systemId': 1068,
'system': <passiogo.TransportationSystem at 0x24a77026a00>}
```
### Stops
You can get all the stops within a given transportation system using `TransportationSystem.getStops()`:
```python
stops = system.getStops()
```
Here, `stops` is a list of [`Stop`](api/#stop) objects. We can look at how much information is available for each route.
```python
stops[0].__dict__
```
```
{'id': '10103',
'routesAndPositions': {'4009': [0]},
'systemId': 1068,
'name': 'Medical Stop',
'latitude': 41.79668374,
'longitude': -87.595753286,
'radius': 36,
'system': <passiogo.TransportationSystem at 0x24a77026850>}
```
If you only wish to get stops for a given route, you can use the `Route.getStops()` method.
```python
stops = routes[0].getStops()
```
### System Alerts
You can get all system alerts within a given transportation system with the `TransportationSystem.getSystemAlerts()`.
```python
alerts = system.getSystemAlerts()
```
Here, `alerts` is a list of [`SystemAlert`](api/#systemalert). We can look at how much information is available for each alert.
```python
alerts[0].__dict__
```
```
{'id': '27535',
'systemId': '1068',
'system': <passiogo.TransportationSystem at 0x24a764e7a90>,
'routeId': None,
'name': 'Nightride Assistance Contact',
'html': 'During the hours of 4 p.m. until 4 a.m., if you do not see arrival times or buses on route in the app, or experience any unusual event, please contact <b>773-573-7201</b> for assistance.',
'archive': '0',
'important': '1',
'dateTimeCreated': '2024-04-09 09:43:10',
'dateTimeFrom': '2024-04-09 15:40:44',
'dateTimeTo': '2025-04-16 09:40:44',
'asPush': '1',
'gtfs': '1',
'gtfsAlertCauseId': None,
'gtfsAlertEffectId': None,
'gtfsAlertUrl': None,
'gtfsAlertHeaderText': 'Nightride Assistance Contact',
'gtfsAlertDescriptionText': 'During the hours of 4 p.m. until 4 a.m., if you do not see arrival times or buses on route in the app, or experience any unusual event, please contact 773-573-7201 for assistance.',
'routeGroupId': None,
'createdUtc': '2024-04-09 14:43:10',
'authorId': '1202',
'author': 'John Appleseed (abc@domain.com)',
'updated': '2024-07-17 16:12:02',
'updateAuthorId': '1217',
'updateAuthor': 'Mark Appleseed (def@domain.com)',
'createdF': 'Tuesday, April 9th, 2024 3:40 PM',
'fromF': 'Tuesday, April 9th, 2024 3:40 PM',
'fromOk': '1',
'toOk': '1'}
```
## Changelog
This project's changelog is available at [`CHANGELOG.md`](https://github.com/athuler/PassioGo/blob/main/CHANGELOG.md)
@@ -39,7 +182,9 @@ Found a bug? Have an idea for a new feature? Please [send it in as a GitHub issu
## Contributing
Interested in contributing to this package? [Fork the repository](https://github.com/athuler/PassioGo/fork), make your edits, then open a pull request!
Interested in contributing to this package? Check out [open issues](https://github.com/athuler/PassioGo/issues).
When ready, [fork the repository](https://github.com/athuler/PassioGo/fork), make your edits, then open a pull request on the active development branch.
## All Transportation Systems Accessible By The API
@@ -53,212 +198,212 @@ Collapsed below are all the transportation systems publicly available through th
<i>Last Updated: 2024/07/14</i><br/><br/>
- 3630 Peachtree<br/>
- 5025 Apartments<br/>
- 725 Ponce<br/>
- Agnes Scott College<br/>
- Alabama A&M University<br/>
- Anne Arundel County Office of Transportation<br/>
- Atlantic Station<br/>
- AUC<br/>
- Audible<br/>
- Augusta University<br/>
- Bayonne Bay<br/>
- Beacon College<br/>
- Beacon Shuttle<br/>
- Beloit Transit<br/>
- Bis-Man Transit<br/>
- Bowie State University<br/>
- Brockton Area Transit Authority (BAT)<br/>
- Bull Runner at USF<br/>
- Cal State San Bernardino<br/>
- Canby Area Transit<br/>
- Cascades East Transit<br/>
- Casper Area Transit<br/>
- Century Village (FT)<br/>
- Chapman University<br/>
- Charles River TMA<br/>
- Charleston Airport REEF<br/>
- Charm City Circulator<br/>
- Chemung County (C-Tran)<br/>
- CHOA<br/>
- Citrus Connection<br/>
- City of Arcadia<br/>
- City of Bangor<br/>
- City of Billings MET Transit<br/>
- City of Cerritos<br/>
- City of Clovis<br/>
- City of Detroit - Employee Shuttle<br/>
- City of Harrisonburg Department of Public Transportation (HDPT)<br/>
- City of Hoboken<br/>
- City of Irvine<br/>
- City of Jackson (JTRAN)<br/>
- City of Jacksonville<br/>
- City of Monterey Park<br/>
- City of Newport Beach (Balboa Peninsula Trolley)<br/>
- City of Olean<br/>
- City of Rosemead<br/>
- City of Sandy<br/>
- City of Tracy (MTM / Tracer Transit)<br/>
- City of Tyler<br/>
- City of Watertown (CitiBus)<br/>
- Citylink Edmond<br/>
- Citylink North (Kootenai County)<br/>
- Citylink South<br/>
- Clackamas County<br/>
- Clemson Tiger Transit<br/>
- Clemson University<br/>
- Coca Cola<br/>
- Colby College<br/>
- Columbia University<br/>
- Concho Valley Transit<br/>
- Concord Kannapolis Area Transit<br/>
- Concourse<br/>
- Connect Douglas<br/>
- Cooperative Alliance for Seacoast Transportation (COAST)<br/>
- Coral Gables<br/>
- CoryD (Test)<br/>
- County Connector<br/>
- CSULB<br/>
- Disney Programs<br/>
- District of Chamblee<br/>
- Drury Plaza Hotel - Disney Springs<br/>
- Eastern Kentucky University<br/>
- Eastern Panhandle Transit Authority (EPTA)<br/>
- Eastern Virginia Medical School<br/>
- Elon University<br/>
- Emory University<br/>
- Endicott College<br/>
- ES Atlanta<br/>
- Escambia County Area Transit (ECAT)<br/>
- ETHRA<br/>
- EWR Employee Shuttle<br/>
- EWR Port Authority NYNJ<br/>
- FIT NY<br/>
- Florham Park (Sun Valley/River Bend)<br/>
- Florida Gulf Coast University (FGCU)<br/>
- Florida International University<br/>
- ForestView/Evergreen/Evergreen East<br/>
- Fort Saskatchewan Transit (PWTransit Canada Ltd.)<br/>
- Franklin Regional Transit Authority<br/>
- Franklin Transit<br/>
- Fresh Direct (Pro Park)<br/>
- Fresno State University<br/>
- GatewayJFK Connection<br/>
- George Washington University (GW)<br/>
- Georgia College & State University (GCSU)<br/>
- Georgia Southern University<br/>
- Georgia State University<br/>
- Georgia Tech<br/>
- GoBus<br/>
- Harford County<br/>
- Harris County Transit<br/>
- HARTransit<br/>
- Harvard University<br/>
- Hendry County Transit System<br/>
- Highland Hospital Metropolis<br/>
- Hill Place Apartments<br/>
- Hollins University<br/>
- Houston Airport (SP+)<br/>
- Hutch Metro Center<br/>
- Interurban Trolley<br/>
- Jasper Transit<br/>
- JFK LGA Shuttles<br/>
- Kentucky River Foothills<br/>
- Key West Transit<br/>
- Lawrence Transit<br/>
- Lehigh University<br/>
- Los Angeles International Airport (LAX)<br/>
- Marymount University<br/>
- Mayaguez (Skytec)<br/>
- McAfee Knob Trailhead (Ridesource)<br/>
- Mercy University<br/>
- Metropolis Parking (Anschutz Campus)<br/>
- Missouri State University<br/>
- MIT<br/>
- Montachusett Regional Transit Authority (MART)<br/>
- National Cancer Institute<br/>
- NC State University<br/>
- New River Transit Authority<br/>
- New York University<br/>
- North Carolina A&T State University<br/>
- North Fork Area Transit<br/>
- Otter Bus (Ridesource)<br/>
- Ozark Regional Transit<br/>
- Palm Beach International Airport Parking Shuttle<br/>
- Pepperdine University<br/>
- Pittsburgh International Airport (PIT)<br/>
- Port of Galveston (LAZ Parking)<br/>
- Portage Area Regional Transit Authority (PARTA)<br/>
- Providence College<br/>
- Quinnipiac University<br/>
- Radford Transit<br/>
- Ravinia<br/>
- River Valley Transit<br/>
- River Valley Transit<br/>
- Roadrunner Transit<br/>
- Rochester Institute of Technology (RIT)<br/>
- Roger Williams University<br/>
- Rutgers University<br/>
- Sacramento Airport Park & Ride<br/>
- Saint Peter's University<br/>
- Sales Demo - SR<br/>
- Seneca Transit System<br/>
- Sioux City Transit<br/>
- SMART Transit<br/>
- South Clackamas Transportation District<br/>
- Southeastern Louisiana University<br/>
- Southern Connecticut State University<br/>
- St. Lawrence County Public Transit<br/>
- St. Vincent's (Pinnacle Transportation Group)<br/>
- State Shuttle (Onyx Equities)<br/>
- STC Atlanta Georgia<br/>
- Stevens Point - Central Transportation<br/>
- Tennessee Technological University<br/>
- Terraces (Pinnacle Transportation Group)<br/>
- The Concord Trolley<br/>
- The Cottages at Lake Tamaha Tuscaloosa<br/>
- The Galleria (Reef Parking)<br/>
- The Hartford<br/>
- The U Apartments Raleigh<br/>
- Township of West Orange<br/>
- Towson Loop (Baltimore County)<br/>
- Tulane University<br/>
- Tuscaloosa Transit Authority<br/>
- UARK (University of Arkansas)<br/>
- UCONN/WRTD<br/>
- UNC Charlotte<br/>
- UNC Greensboro (UNCG)<br/>
- UNC Wilmington<br/>
- University at Buffalo<br/>
- University of Alabama<br/>
- University of Chicago<br/>
- University of Florida (UF)<br/>
- University of Georgia (UGA)<br/>
- University of Hartford<br/>
- University of Miami Medical Center (Reef Parking)<br/>
- University of Michigan-Dearborn<br/>
- University of Montana (ASUM)<br/>
- University of New Haven<br/>
- University of New Mexico (UNM)<br/>
- University of North Georgia<br/>
- University of Rochester<br/>
- University of San Diego Tram Services<br/>
- University of Texas at El Paso (UTEP)<br/>
- University of Wisconsin-Milwaukee<br/>
- Upper Cumberland Human Resource Agency (UCHRA)<br/>
- Utah State University<br/>
- Vanderbilt University<br/>
- Vanderbilt University Medical Center<br/>
- Via Mobility Services<br/>
- VMware<br/>
- Wake Forest University<br/>
- WaterColor Community Association<br/>
- West Midtown Shuttle<br/>
- Western Carolina University<br/>
- WestMar<br/>
- Woodbridge Village/Gardens/Colonial<br/>
- XChange at Secaucus Junction<br/>
- 3630 Peachtree (#951)<br/>
- 5025 Apartments (#1634)<br/>
- 725 Ponce (#1832)<br/>
- Agnes Scott College (#1471)<br/>
- Alabama A&M University (#2456)<br/>
- Anne Arundel County Office of Transportation (#3469)<br/>
- Atlantic Station (#4349)<br/>
- AUC (#67)<br/>
- Audible (#876)<br/>
- Augusta University (#553)<br/>
- Bayonne Bay (#1808)<br/>
- Beacon College (#3389)<br/>
- Beacon Shuttle (#3561)<br/>
- Beloit Transit (#3655)<br/>
- Bis-Man Transit (#4121)<br/>
- Bowie State University (#3001)<br/>
- Brockton Area Transit Authority (BAT) (#2046)<br/>
- Bull Runner at USF (#2343)<br/>
- Cal State San Bernardino (#1187)<br/>
- Canby Area Transit (#3274)<br/>
- Cascades East Transit (#2460)<br/>
- Casper Area Transit (#4055)<br/>
- Century Village (FT) (#444)<br/>
- Chapman University (#263)<br/>
- Charles River TMA (#5019)<br/>
- Charleston Airport REEF (#4749)<br/>
- Charm City Circulator (#3554)<br/>
- Chemung County (C-Tran) (#4009)<br/>
- CHOA (#3489)<br/>
- Citrus Connection (#1752)<br/>
- City of Arcadia (#3304)<br/>
- City of Bangor (#4631)<br/>
- City of Billings MET Transit (#3901)<br/>
- City of Cerritos (#2282)<br/>
- City of Clovis (#3743)<br/>
- City of Detroit - Employee Shuttle (#1275)<br/>
- City of Harrisonburg Department of Public Transportation (HDPT) (#2868)<br/>
- City of Hoboken (#466)<br/>
- City of Irvine (#4502)<br/>
- City of Jackson (JTRAN) (#3363)<br/>
- City of Jacksonville (#3521)<br/>
- City of Monterey Park (#3215)<br/>
- City of Newport Beach (Balboa Peninsula Trolley) (#4883)<br/>
- City of Olean (#2084)<br/>
- City of Rosemead (#3670)<br/>
- City of Sandy (#3183)<br/>
- City of Tracy (MTM / Tracer Transit) (#2996)<br/>
- City of Tyler (#3777)<br/>
- City of Watertown (CitiBus) (#2775)<br/>
- Citylink Edmond (#4662)<br/>
- Citylink North (Kootenai County) (#2016)<br/>
- Citylink South (#2059)<br/>
- Clackamas County (#3205)<br/>
- Clemson Tiger Transit (#1654)<br/>
- Clemson University (#793)<br/>
- Coca Cola (#416)<br/>
- Colby College (#3377)<br/>
- Columbia University (#74)<br/>
- Concho Valley Transit (#3281)<br/>
- Concord Kannapolis Area Transit (#4124)<br/>
- Concourse (#1841)<br/>
- Connect Douglas (#1661)<br/>
- Cooperative Alliance for Seacoast Transportation (COAST) (#2962)<br/>
- Coral Gables (#2787)<br/>
- CoryD (Test) (#829)<br/>
- County Connector (#2933)<br/>
- CSULB (#4163)<br/>
- Disney Programs (#2208)<br/>
- District of Chamblee (#1897)<br/>
- Drury Plaza Hotel - Disney Springs (#4748)<br/>
- Eastern Kentucky University (#3828)<br/>
- Eastern Panhandle Transit Authority (EPTA) (#1298)<br/>
- Eastern Virginia Medical School (#591)<br/>
- Elon University (#3045)<br/>
- Emory University (#4432)<br/>
- Endicott College (#2873)<br/>
- ES Atlanta (#2280)<br/>
- Escambia County Area Transit (ECAT) (#2283)<br/>
- ETHRA (#4583)<br/>
- EWR Employee Shuttle (#2989)<br/>
- EWR Port Authority NYNJ (#2496)<br/>
- FIT NY (#973)<br/>
- Florham Park (Sun Valley/River Bend) (#2311)<br/>
- Florida Gulf Coast University (FGCU) (#2281)<br/>
- Florida International University (#4119)<br/>
- ForestView/Evergreen/Evergreen East (#1641)<br/>
- Fort Saskatchewan Transit (PWTransit Canada Ltd.) (#912)<br/>
- Franklin Regional Transit Authority (#2771)<br/>
- Franklin Transit (#1652)<br/>
- Fresh Direct (Pro Park) (#4691)<br/>
- Fresno State University (#805)<br/>
- GatewayJFK Connection (#2125)<br/>
- George Washington University (GW) (#4120)<br/>
- Georgia College & State University (GCSU) (#895)<br/>
- Georgia Southern University (#137)<br/>
- Georgia State University (#480)<br/>
- Georgia Tech (#76)<br/>
- GoBus (#1839)<br/>
- Harford County (#4620)<br/>
- Harris County Transit (#3497)<br/>
- HARTransit (#2250)<br/>
- Harvard University (#831)<br/>
- Hendry County Transit System (#2217)<br/>
- Highland Hospital Metropolis (#3829)<br/>
- Hill Place Apartments (#1092)<br/>
- Hollins University (#3014)<br/>
- Houston Airport (SP+) (#4919)<br/>
- Hutch Metro Center (#1569)<br/>
- Interurban Trolley (#3639)<br/>
- Jasper Transit (#4294)<br/>
- JFK LGA Shuttles (#2494)<br/>
- Kentucky River Foothills (#3630)<br/>
- Key West Transit (#4440)<br/>
- Lawrence Transit (#4834)<br/>
- Lehigh University (#1090)<br/>
- Los Angeles International Airport (LAX) (#1421)<br/>
- Marymount University (#4716)<br/>
- Mayaguez (Skytec) (#3206)<br/>
- McAfee Knob Trailhead (Ridesource) (#3069)<br/>
- Mercy University (#694)<br/>
- Metropolis Parking (Anschutz Campus) (#3282)<br/>
- Missouri State University (#459)<br/>
- MIT (#94)<br/>
- Montachusett Regional Transit Authority (MART) (#2173)<br/>
- National Cancer Institute (#3293)<br/>
- NC State University (#3827)<br/>
- New River Transit Authority (#3362)<br/>
- New York University (#1007)<br/>
- North Carolina A&T State University (#261)<br/>
- North Fork Area Transit (#2587)<br/>
- Otter Bus (Ridesource) (#3015)<br/>
- Ozark Regional Transit (#1589)<br/>
- Palm Beach International Airport Parking Shuttle (#1071)<br/>
- Pepperdine University (#3593)<br/>
- Pittsburgh International Airport (PIT) (#3200)<br/>
- Port of Galveston (LAZ Parking) (#3294)<br/>
- Portage Area Regional Transit Authority (PARTA) (#3420)<br/>
- Providence College (#4147)<br/>
- Quinnipiac University (#3899)<br/>
- Radford Transit (#1248)<br/>
- Ravinia (#1593)<br/>
- River Valley Transit (#1726)<br/>
- River Valley Transit (#5168)<br/>
- Roadrunner Transit (#4010)<br/>
- Rochester Institute of Technology (RIT) (#4006)<br/>
- Roger Williams University (#1850)<br/>
- Rutgers University (#1268)<br/>
- Sacramento Airport Park & Ride (#898)<br/>
- Saint Peter's University (#493)<br/>
- Sales Demo - SR (#5047)<br/>
- Seneca Transit System (#2035)<br/>
- Sioux City Transit (#4832)<br/>
- SMART Transit (#4476)<br/>
- South Clackamas Transportation District (#4233)<br/>
- Southeastern Louisiana University (#186)<br/>
- Southern Connecticut State University (#431)<br/>
- St. Lawrence County Public Transit (#4234)<br/>
- St. Vincent's (Pinnacle Transportation Group) (#2561)<br/>
- State Shuttle (Onyx Equities) (#2780)<br/>
- STC Atlanta Georgia (#2197)<br/>
- Stevens Point - Central Transportation (#2556)<br/>
- Tennessee Technological University (#1736)<br/>
- Terraces (Pinnacle Transportation Group) (#3270)<br/>
- The Concord Trolley (#3089)<br/>
- The Cottages at Lake Tamaha Tuscaloosa (#1093)<br/>
- The Galleria (Reef Parking) (#1900)<br/>
- The Hartford (#4581)<br/>
- The U Apartments Raleigh (#1650)<br/>
- Township of West Orange (#3166)<br/>
- Towson Loop (Baltimore County) (#2153)<br/>
- Tulane University (#353)<br/>
- Tuscaloosa Transit Authority (#3817)<br/>
- UARK (University of Arkansas) (#3778)<br/>
- UCONN/WRTD (#1541)<br/>
- UNC Charlotte (#1053)<br/>
- UNC Greensboro (UNCG) (#2874)<br/>
- UNC Wilmington (#3952)<br/>
- University at Buffalo (#4882)<br/>
- University of Alabama (#240)<br/>
- University of Chicago (#1068)<br/>
- University of Florida (UF) (#3826)<br/>
- University of Georgia (UGA) (#3994)<br/>
- University of Hartford (#3305)<br/>
- University of Miami Medical Center (Reef Parking) (#4201)<br/>
- University of Michigan-Dearborn (#1481)<br/>
- University of Montana (ASUM) (#4041)<br/>
- University of New Haven (#3900)<br/>
- University of New Mexico (UNM) (#2156)<br/>
- University of North Georgia (#646)<br/>
- University of Rochester (#3214)<br/>
- University of San Diego Tram Services (#3444)<br/>
- University of Texas at El Paso (UTEP) (#2383)<br/>
- University of Wisconsin-Milwaukee (#728)<br/>
- Upper Cumberland Human Resource Agency (UCHRA) (#2875)<br/>
- Utah State University (#3499)<br/>
- Vanderbilt University (#3622)<br/>
- Vanderbilt University Medical Center (#1332)<br/>
- Via Mobility Services (#4729)<br/>
- VMware (#1274)<br/>
- Wake Forest University (#3669)<br/>
- WaterColor Community Association (#4842)<br/>
- West Midtown Shuttle (#4473)<br/>
- Western Carolina University (#2597)<br/>
- WestMar (#1091)<br/>
- Woodbridge Village/Gardens/Colonial (#1642)<br/>
- XChange at Secaucus Junction (#432)<br/>
</details>
<br/>
+360 -11
View File
@@ -1,22 +1,371 @@
# API Reference
## `getAllRoutes`
## `getSystems()`
Obtains every route for the selected system.
Gets all systems supported by PassioGo.
**getAllRoutes**(systemSelected = 1068, paramDigit = 1, amount = 1)
**Inputs**:
- **systemSelected**:
- **paramDigit**:
- **amount**:
- **appVersion** (*int*): Version of the application (Default: 2)
- **sortMode** (*int*): Unknown (Default: 1)
**Returns**: *list* of [`TransportationSystem`](#transportationsystem)
```python
passiogo.getSystems()
```
```
[<passiogo.TransportationSystem at 0x1d62cb54a30>,
<passiogo.TransportationSystem at 0x1d62cb54b20>,
<passiogo.TransportationSystem at 0x1d62d8bb310>,
...
<passiogo.TransportationSystem at 0x1d62d599be0>,
<passiogo.TransportationSystem at 0x1d62d599c10>]
```
## `getSystemFromID()`
Gets the system with the corresponding id. If there is no match, returns *None*.
**Inputs**:
- **appVersion** (*int*): Version of the application (Default: 2)
- **sortMode** (*int*): Unknown (Default: 1)
**Returns**: [`TransportationSystem`](#transportationsystem) or *None* if no match
```python
passiogo.getSystemFromID(1068)
```
```
<passiogo.TransportationSystem at 0x1d62da31550>
```
## `TransportationSystem`
### `TransportationSystem.__init__()`
**id** is the only required parameter, all other default to *None*.
- **id** (*int*): ID of the system
- **name** (*str*): The full name of the system
- **username** (*str*): URL-friendly system name
- **goAgencyName** (*str*): Display name of the system
- **email** (*str*): Contact email address for the system
- **goTestMode** (*bool*): Unknown
- **name2** (*bool*): Unknown
- **homepage** (*str*): URL to the agency's homepage
- **logo** (*bool*): Unknown
- **goRoutePlannerEnabled** (*bool*): Unknown
- **goColor** (*str*): Unknown
- **goSupportEmail** (*str*): Unknown
- **goSharedCode** (*int*): Unknown
- **goAuthenticationType** (*bool*): Unknown
```json
{'id': 1068,
'name': 'University of Chicago',
'username': 'chicago',
'goAgencyName': 'University of Chicago',
'email': 'bus@uchicago.edu',
'goTestMode': False,
'name2': False,
'homepage': 'https://safety-security.uchicago.edu/en/transportation',
'logo': True,
'goRoutePlannerEnabled': False,
'goColor': '#843c39',
'goSupportEmail': 'bus@uchicago.edu',
'goSharedCode': 1312,
'goAuthenticationType': False}
```
### `TransportationSystem.getRoutes()`
Get all routes for the appropriate system.
**Input**:
- **appVersion** (*int*): Version of the application (Default: 1)
- **amount** (*int*): Unknown (Default: 1)
**Output**: *List* of [`Route`](#route)
```python
passiogo.getSystemFromID(1068).getRoutes()
```
```
[<passiogo.Route at 0x1d62db3fac0>,
<passiogo.Route at 0x1d62db3f520>,
<passiogo.Route at 0x1d62db3f790>,
<passiogo.Route at 0x1d62db3fdc0>,
<passiogo.Route at 0x1d62db3fa90>,
<passiogo.Route at 0x1d62db3ff10>,
<passiogo.Route at 0x1d62db3f2e0>,
<passiogo.Route at 0x1d62db3f310>,
<passiogo.Route at 0x1d62db3fb20>,
<passiogo.Route at 0x1d62db3f4f0>,
<passiogo.Route at 0x1d62db3f8e0>,
<passiogo.Route at 0x1d62db3fbb0>,
<passiogo.Route at 0x1d62db3fa30>,
<passiogo.Route at 0x1d62db3f5e0>,
<passiogo.Route at 0x1d62db3f220>,
<passiogo.Route at 0x1d62db3f1c0>,
<passiogo.Route at 0x1d62db3fca0>]
```
### `TransportationSystem.getStops()`
Gets all stops for the given transportation system.
**Inputs**:
- **appVersion** (*int*): Version of the application (Default: 2)
- **sA** (*int*): Unknown (Default: 1)
**Output**: *List* of [`Stop`](#stop)
```python
passiogo.getSystemFromID(1068).getStops()
```
```
[<passiogo.Stop at 0x1d62c89a670>,
<passiogo.Stop at 0x1d62d2adc10>,
<passiogo.Stop at 0x1d62d57bac0>,
<passiogo.Stop at 0x1d62d57b5b0>,
<passiogo.Stop at 0x1d62d57b520>,
<passiogo.Stop at 0x1d62d57b3d0>,
<passiogo.Stop at 0x1d62d57ba60>,
<passiogo.Stop at 0x1d62d57bd90>,
<passiogo.Stop at 0x1d62d57bee0>,
...
<passiogo.Stop at 0x1d62da5a700>]
```
### `TransportationSystem.getSystemAlerts()`
Gets all alerts for the corresponding transportation system.
**Inputs**:
- **appVersion** (*int*): Version of the application (Default: 1)
- **amount** (*int*): Unknown (Default: 1)
- **routesAmount** (*int*): Unknown (Default: 1)
**Output**: *List* of [`SystemAlert`](#systemalert)
```python
passiogo.getSystemFromID(1068).getSystemAlerts()
```
```
[<passiogo.SystemAlert at 0x1d62dbe0130>,
<passiogo.SystemAlert at 0x1d62dbe0190>,
<passiogo.SystemAlert at 0x1d62dbe0370>,
<passiogo.SystemAlert at 0x1d62dbe0490>]
```
## `Route`
### `Route.__init__()`
**id** is the only required parameter, all other default to *None*.
- **id** (*int*): ID of the route
- **groupId** (*int*): Unknown
- **groupColor** (*str*): Unknown
- **name** (*str*): Name of the route
- **shortName** (*str*): Short name / abbreviation of the route
- **nameOrig** (*str*): Unknown
- **fullname** (*str*): Unknown
- **myid** (*int*): Unknown
- **mapApp** (*bool*): Unknown
- **archive** (*bool*): Unknown
- **goPrefixRouteName** (*bool*): Unknown
- **goShowSchedule** (*bool*): Unknown
- **outdated** (*bool*): Unknown
- **distance** (*int*): Unknown
- **latitude** (*float*): Unknown
- **longitude** (*float*): Unknown
- **timezone** (*str*): Timezone of the route
- **serviceTime** (*str*): Route Schedule
- **serviceTimeShort** (*str*): Route Schedule
- **systemId** (*int*): ID of the transportation system
- **system** (*[`TransportationSystem`](#transportationsystem)*): transportation system object
```json
{'id': '133007',
'groupId': '5702',
'groupColor': '#0000ff',
'name': 'Apostolic',
'shortName': 'AP',
'nameOrig': 'Apostolic',
'fullname': 'University of Chicago',
'myid': '38729',
'mapApp': '1',
'archive': '0',
'goPrefixRouteName': '1',
'goShowSchedule': 1,
'outdated': '1',
'distance': 578,
'latitude': '41.780867018',
'longitude': '-87.592902254',
'serviceTime': 'is not provided: no bus on the route',
'serviceTimeShort': 'No bus in service',
'systemId': 1068,
'system': <passiogo.TransportationSystem at 0x1d62db57c10>}
```
### `Route.getStops()`
Gets the list of stops for this route and stores it as an argument
**Output**: *List* of [`Stop`](#stop)
```python
passiogo.getSystemFromID(1068).getRoutes()[0].getStops()
```
```
[<passiogo.Stop at 0x24a762ad250>,
<passiogo.Stop at 0x24a762ada60>,
<passiogo.Stop at 0x24a762ad850>,
<passiogo.Stop at 0x24a762ad0d0>,
<passiogo.Stop at 0x24a762ad2b0>,
<passiogo.Stop at 0x24a75deabe0>,
<passiogo.Stop at 0x24a75deae80>,
<passiogo.Stop at 0x24a75dea790>,
<passiogo.Stop at 0x24a75dead60>]
```
## `Stop`
### `Stop.__init__()`
**id** is the only required parameter, all other default to *None*.
- **id** (*str*): ID of the stop
- **routeId** (*str*): ID of the route
- **systemId** (*int*): ID of the transportation system
- **position** (*int*): Unknown
- **name** (*str*): Name of the stop
- **latitude** (*float*): Latitude of the stop
- **longitude** (*float*): Longitude of the stop
- **radius** (*int*): Unknown
- **routeName** (*str*): Name of the route
- **routeShortname** (*str*): Short Name / Abbreviation of the route
- **routeGroupId** (*int*): Unknown
- **system** (*[`TransportationSystem`](#transportationsystem)*): Transportation system object
- **route** (*[`Route`](#route)*): Route object
```json
{'id': '8611',
'routesAndPositions': {'38728': [0, 7], '38730': [7]},
'systemId': 1068,
'name': 'Drexel Garage',
'latitude': 41.784433,
'longitude': -87.604445,
'radius': 75,
'system': <passiogo.TransportationSystem at 0x24a7681b670>}
```
## `SystemAlert`
### `SystemAlert.__init__()`
**id** is the only required parameter, all other default to *None*.
- **id** (*int*): ID of the alert
- **systemId** (*int*): ID of the system
- **system** (*[`TransportationSystem`](#transportationsystem)*): Transportation System object
- **routeId** (*int*): Route ID this alert relates to
- **name** (*str*): Name/Title of the alert
- **html** (*str*): Content of the alert in HTML format
- **archive** (*bool*): Unknown
- **important** (*bool*): Unknown
- **dateTimeCreated** (*str*): Date and time when the alert was created
- **dateTimeFrom** (*str*): Start date and time from which the alert is in effect
- **dateTimeTo** (*str*): End date and time from which the alert is in effect
- **asPush** (*bool*): Unknown
- **gtfs** (*bool*): Unknown
- **gtfsAlertCauseId** (*bool*): Unknown
- **gtfsAlertEffectId** (*bool*): Unknown
- **gtfsAlertUrl** (*str*): Unknown
- **gtfsAlertHeaderText** (*str*): Name/Title of the alert in text format
- **gtfsAlertDescriptionText** (*str*): Content of the alert in text format
- **routeGroupId** (*int*): Unknown
- **createdUtc** (*str*): Date and time when the alert was created in UTC
- **authorId** (*int*): User ID of the author
- **author** (*str*): Name and email of the author
- **updated** (*str*): Date and time when the alert was updated
- **updateAuthorId** (*int*): User ID of the author of the update
- **updateAuthor** (*str*): Name and email of the author of the update
- **createdF** (*str*): Human friendly date and time when the alert was created
- **fromF** (*str*): Human friendly start date and time of the alert
- **fromOk** (*bool*): Unknown
- **toOk** (*bool*): Unknown
```json
{'id': '27926',
'systemId': '1068',
'system': <passiogo.TransportationSystem at 0x1d62ddcc760>,
'routeId': '38731',
'name': 'Midway Metra Reroute',
'html': 'Due to road reconstruction at 60th & Stony Island, Midway Metra will detour to Dorchester Ave., bypassing the parking lot at Stony Island. The new stop for the parking lot is on the Midway EB, across from the Stony Island Parking Lot.',
'archive': '0',
'important': '1',
'dateTimeCreated': '2024-04-18 10:17:44',
'dateTimeFrom': '2024-07-12 06:10:34',
'dateTimeTo': '2024-07-30 22:15:34',
'asPush': '1',
'gtfs': '1',
'gtfsAlertCauseId': None,
'gtfsAlertEffectId': None,
'gtfsAlertUrl': None,
'gtfsAlertHeaderText': 'Midway Metra Reroute',
'gtfsAlertDescriptionText': 'Due to road reconstruction at 60th Stony Island, Midway Metra will detour to Dorchester Ave., bypassing the parking lot at Stony Island. The new stop for the parking lot is on the Midway EB, across from the Stony Island Parking Lot.',
'routeGroupId': None,
'createdUtc': '2024-04-18 15:17:44',
'authorId': '1217',
'author': 'John Appleseed (sample@email.com)',
'updated': '2024-07-12 06:09:22',
'updateAuthorId': '1202',
'updateAuthor': 'John Appleseed (sample@email.com)',
'createdF': 'Friday, July 12th, 2024 6:10 AM',
'fromF': 'Friday, July 12th, 2024 6:10 AM',
'fromOk': '1',
'toOk': '1'}
```
## `printAllSystemsMd()`
Prints all system names as a markdown list.
**Input**:
- **includeHtmlBreaks** (*bool*): Whether to include HTML line breaks (Default: True)
**Returns**: None
```python
passiogo.printAllSystemsMd()
```
```md
- 3630 Peachtree (#951)<br/>
- 5025 Apartments (#1634)<br/>
- 725 Ponce (#1832)<br/>
- Agnes Scott College (#1471)<br/>
...
```
## `getAllStops`
## `getSystemAlerts`
## `getBuses`
## `getSystems`
## `printAllSystemsMd`
+3
View File
@@ -0,0 +1,3 @@
# Examples
-18
View File
@@ -1,18 +0,0 @@
# Usage
## Installation
Install using pip
```
pip install passiogo
```
## Identify Transportation System
Before you can do anything, you will need to identify the `id` of the transportation system you are interested in querying.
```python
```
+5 -2
View File
@@ -7,7 +7,7 @@ site_author: Andrei Thüler
nav:
- Home: index.md
- Usage: usage.md
# - Examples: examples.md
- API Reference: api.md
- Changelog: changelog.md
@@ -15,4 +15,7 @@ nav:
# - search
markdown_extensions:
- markdown_include.include:
base_path: .
base_path: .
watch:
- README.md
+542 -125
View File
@@ -1,18 +1,29 @@
import json
import requests
import websocket
import json
BASE_URL = "https://passiogo.com"
### Helper Functions ###
def toIntInclNone(toInt):
if toInt == None:
return toInt
return(int(toInt))
def sendApiRequest(url, body):
# Send Request
response = requests.post(url, json = body)
# Handle JSON Response
response = response.json()
try:
# Handle JSON Response
response = response.json()
except Exception as e:
raise Exception(f"Error converting API response to JSON! Here is the response received: {response}")
return None
# Handle API Error
@@ -25,106 +36,550 @@ def sendApiRequest(url, body):
return(response)
def getAllRoutes(
systemSelected,
paramDigit = 1,
amount = 1
):
"""
Obtains every route for the selected system.
=========
systemSelected: system from which to get content
paramDigit: does not affect content of response, only formatting
amount:
1: Returns all routes for given system
0: Not Valid, Gives Error
>=2: Returns all routes for given system in addition to unrelated routes. Exact methodology unsure.
"""
### Transportation Systems ###
class TransportationSystem:
def __init__(
self,
id: int,
name: str = None,
username: str = None,
goAgencyName: str = None,
email: str = None,
goTestMode: bool = None,
name2: bool = None,
homepage: str = None,
logo: bool = None,
goRoutePlannerEnabled: bool = None,
goColor: str = None,
goSupportEmail: str = None,
goSharedCode: int = None,
goAuthenticationType: bool = None
):
self.id = id
self.name = name
self.username = username
self.goAgencyName = goAgencyName
self.email = email
self.goTestMode = goTestMode
self.name2 = name2
self.homepage = homepage
self.logo = logo
self.goRoutePlannerEnabled = goRoutePlannerEnabled
self.goColor = goColor
self.goSupportEmail = goSupportEmail
self.goSharedCode = goSharedCode
self.goAuthenticationType = goAuthenticationType
self.checkTypes()
def checkTypes(self):
# id : int
assert type(self.id) == int, f"'id' parameter must be an int not {type(self.id)}"
# name : str or None
assert (type(self.name) == str or self.name is None), f"'name' parameter must be a str not {type(self.name)}"
# username : str or None
assert (type(self.username) == str or self.username is None), f"'username' parameter must be a str not {type(self.username)}"
# goAgencyName : str or None
assert (type(self.goAgencyName) == str or self.goAgencyName is None), f"'goAgencyName' parameter must be a str not {type(self.goAgencyName)}"
# email : str or None
assert (type(self.email) == str or self.email is None), f"'email' parameter must be a str not {type(self.email)}"
# goTestMode : bool or None
assert (type(self.goTestMode) == bool or self.goTestMode is None), f"'goTestMode' parameter must be a bool not {type(self.goTestMode)}"
# name2 : bool or None
assert (type(self.name2) == bool or self.name2 is None), f"'name2' parameter must be a bool not {type(self.name2)}"
# homepage : str or None
assert (type(self.homepage) == str or self.homepage is None), f"'homepage' parameter must be a str not {type(self.homepage)}"
# logo : bool or None
assert (type(self.logo) == bool or self.logo is None), f"'logo' parameter must be a bool not {type(self.logo)}"
# goRoutePlannerEnabled : bool or None
assert (type(self.goRoutePlannerEnabled) == bool or self.goRoutePlannerEnabled is None), f"'goRoutePlannerEnabled' parameter must be a bool not {type(self.goRoutePlannerEnabled)}"
# goColor : str or None
assert (type(self.goColor) == str or self.goColor is None), f"'goColor' parameter must be a str not {type(self.goColor)}"
# goSupportEmail : str or None
assert (type(self.goSupportEmail) == str or self.goSupportEmail is None), f"'goSupportEmail' parameter must be a str not {type(self.goSupportEmail)}"
# goSharedCode : int or None
assert (type(self.goSharedCode) == int or self.goSharedCode is None), f"'goSharedCode' parameter must be a int not {type(self.goSharedCode)}"
# goAuthenticationType : bool or None
assert (type(self.goAuthenticationType) == bool or self.goAuthenticationType is None), f"'goAuthenticationType' parameter must be a bool not {type(self.goAuthenticationType)}"
def getRoutes(
self,
appVersion = 1,
amount = 1
) -> list["Route"]:
"""
Obtains every route for the selected system.
=========
systemSelected: system from which to get content
paramDigit: does not affect content of response, only formatting
amount:
1: Returns all routes for given system
0: Not Valid, Gives Error
>=2: Returns all routes for given system in addition to unrelated routes. Exact methodology unsure.
"""
# Initialize & Send Request
url = BASE_URL+f"/mapGetData.php?getRoutes={appVersion}"
body = {
"systemSelected0" : str(self.id),
"amount" : amount
}
routes = sendApiRequest(url, body)
# Handle Request Error
if(routes == None):
return(None)
# Handle Differing Response Format
if "all" in routes:
routes = routes["all"]
allRoutes = []
for digit, route in routes.items():
possibleKeys = ["id", "groupId", "groupColor", "name", "shortName", "nameOrig", "fullname", "myid", "mapApp", "archive", "goPrefixRouteName", "goShowSchedule", "outdated", "distance", "latitude", "longitude", "timezone", "serviceTime", "serviceTimeShort"]
for possibleKey in possibleKeys:
if possibleKey not in route.keys():
route[possibleKey] = None
allRoutes.append(Route(
id = route["id"],
groupId = route["groupId"],
groupColor = route["groupColor"],
name = route["name"],
shortName = route["shortName"],
nameOrig = route["nameOrig"],
fullname = route["fullname"],
myid = route["myid"],
mapApp = route["mapApp"],
archive = route["archive"],
goPrefixRouteName = route["goPrefixRouteName"],
goShowSchedule = route["goShowSchedule"],
outdated = route["outdated"],
distance = route["distance"],
latitude = route["latitude"],
longitude = route["longitude"],
timezone = route["timezone"],
serviceTime = route["serviceTime"],
serviceTimeShort = route["serviceTimeShort"],
systemId = int(route["userId"]),
system = self
))
return(allRoutes)
def getStops(
self,
appVersion = 2,
sA = 1,
raw = False
) -> list["Stop"]:
"""
Obtains all stop for the given system.
=========
appVersion: No discernible change
sA:
0: error
1: Returns all stops for the given system
>=2: Returns unrelated stops as well
"""
# Initialize & Send Request
url = BASE_URL+"/mapGetData.php?getStops="+str(appVersion)
body = {
"s0" : str(self.id),
"sA" : sA
}
stops = sendApiRequest(url, body)
# Handle Request Error
if(stops == None):
return(None)
if raw:
return(stops)
# Create Route & Stops Dictionary
# {routeid -> [stopid, stopid]}
routesAndStops = {}
for routeId, route in stops["routes"].items():
routesAndStops[routeId] = []
for stop in route[2:]:
if stop == 0:
continue
routesAndStops[routeId].append(stop[1])
# Create Each Stop Object
allStops = []
for id, stop in stops["stops"].items():
# Create Route & Positions Dictionary
# {routeid -> [position]}
routesAndPositions = {}
for routeId in routesAndStops.keys():
if stop["id"] not in routesAndStops[routeId]:
continue
routesAndPositions[routeId] = [i for i,x in enumerate(routesAndStops[routeId]) if x == stop["id"]]
keys = ["userId", "radius"]
for key in keys:
if key not in stop:
stop[key] = None
allStops.append(Stop(
id = stop["id"],
routesAndPositions = routesAndPositions,
systemId = None if stop["userId"] is None else int(stop["userId"]),
name = stop["name"],
latitude = stop["latitude"],
longitude = stop["longitude"],
radius = stop["radius"],
system = self,
))
return(allStops)
def getSystemAlerts(
self,
appVersion = 1,
amount = 1,
routesAmount = 0
) -> list["SystemAlert"]:
"""
Gets all system alerts for the selected system.
=========
systemSelected: system from which to get content
appVersion:
0: Error
>=1: Valid
"""
# Initialize & Send Request
url = BASE_URL+f"/goServices.php?getAlertMessages={appVersion}"
body = {
"systemSelected0" : str(self.id),
"amount" : amount,
"routesAmount":routesAmount
}
errorMsgs = sendApiRequest(url, body)
# Handle Request Error
if(errorMsgs == None):
return(None)
# Create SystemAlert Objects
allAlerts = []
for errorMsg in errorMsgs["msgs"]:
allAlerts.append(SystemAlert(
id = errorMsg["id"],
systemId = errorMsg["userId"],
system = self,
routeId = errorMsg["routeId"],
name = errorMsg["name"],
html = errorMsg["html"],
archive = errorMsg["archive"],
important = errorMsg["important"],
dateTimeCreated = errorMsg["created"],
dateTimeFrom = errorMsg["from"],
dateTimeTo = errorMsg["to"],
asPush = errorMsg["asPush"],
gtfs = errorMsg["gtfs"],
gtfsAlertCauseId = errorMsg["gtfsAlertCauseId"],
gtfsAlertEffectId = errorMsg["gtfsAlertEffectId"],
gtfsAlertUrl = errorMsg["gtfsAlertUrl"],
gtfsAlertHeaderText = errorMsg["gtfsAlertHeaderText"],
gtfsAlertDescriptionText = errorMsg["gtfsAlertDescriptionText"],
routeGroupId = errorMsg["routeGroupId"],
createdUtc = errorMsg["createdUtc"],
authorId = errorMsg["authorId"],
author = errorMsg["author"],
updated = errorMsg["updated"],
updateAuthorId = errorMsg["updateAuthorId"],
updateAuthor = errorMsg["updateAuthor"],
createdF = errorMsg["createdF"],
fromF = errorMsg["fromF"],
fromOk = errorMsg["fromOk"],
toOk = errorMsg["toOk"],
))
return(allAlerts)
def getSystems(
appVersion = 2,
sortMode = 1,
) -> list["TransportationSystem"]:
'''
Gets all systems. Returns a list of TransportationSystem.
sortMode: Unknown
appVersion:
<2: Error
2: Valid
'''
# Initialize & Send Request
url = BASE_URL+"/mapGetData.php?getRoutes="+str(paramDigit)
body = {
"systemSelected0" : str(systemSelected),
"amount" : amount
}
routes = sendApiRequest(url, body)
url = f"{BASE_URL}/mapGetData.php?getSystems={appVersion}&sortMode={sortMode}&credentials=1"
systems = sendApiRequest(url, None)
# Handle Request Error
if(routes == None):
return(None)
# Handle Differing Response Format
if "all" in routes:
routes = routes["all"]
if(systems == None):
return([])
return(routes)
allSystems = []
for system in systems["all"]:
# Convert Empty Strings To None Objects
for parameter in system.keys():
if system[parameter] == '':
system[parameter] = None
try:
allSystems.append(TransportationSystem(
id = int(system["id"]),
name = system["fullname"],
username = system["username"],
goAgencyName = system["goAgencyName"],
email = system["email"],
goTestMode = bool(int(system["goTestMode"])),
name2 = bool(int(system["name2"])),
homepage = system["homepage"],
logo = bool(int(system["logo"])),
goRoutePlannerEnabled = bool(int(system["goRoutePlannerEnabled"])),
goColor = system["goColor"],
goSupportEmail = system["goSupportEmail"],
goSharedCode = toIntInclNone(system["goSharedCode"]),
goAuthenticationType = bool(int(system["goAuthenticationType"])),
))
except Exception as e:
print(e)
print(system)
return()
return(allSystems)
def getAllStops(
systemSelected,
paramDigit = 2,
sA = 1,
debug = 0
def getSystemFromID(
id,
appVersion = 2,
sortMode = 1,
) -> TransportationSystem:
# Check Input Type
assert type(id) == int, "`id` must be of type int"
# Check App Version Type
assert type(appVersion) == int, "`appVersion` must be of type int"
# Check sort Mode Type
assert type(sortMode) == int, "`sortMode` must be of type int"
systems = getSystems(appVersion,sortMode)
for system in systems:
if system.id == id:
return system
return None
def printAllSystemsMd(
includeHtmlBreaks = True
):
"""
Obtains all stop for the selected system.
=========
systemSelected: system from which to get content
paramDigit: No discernable change
sA:
0: error
1: Returns all stops for the given system
>=2: Returns unrelated stops as well
"""
systems = getSystems()
# Initialize & Send Request
url = BASE_URL+"/mapGetData.php?getStops="+str(paramDigit)
body = {
"s0" : str(systemSelected),
"sA" : sA
}
stops = sendApiRequest(url, body)
# Handle Request Error
if(stops == None):
return(None)
return(stops)
for system in systems:
print(f"- {system.name} (#{system.id}){'<br/>' if includeHtmlBreaks else ''}")
def getSystemAlerts(
systemSelected,
paramDigit = 1
):
"""
Gets all system alerts for the selected system.
=========
systemSelected: system from which to get content
paramDigit:
0: Error
>=1: Valid
"""
### Routes ###
class Route:
def __init__(
self,
id: int,
groupId: int = None,
groupColor: str = None,
name: str = None,
shortName: str = None,
nameOrig: str = None,
fullname: str = None,
myid: int = None,
mapApp: bool = None,
archive: bool = None,
goPrefixRouteName: bool = None,
goShowSchedule: bool = None,
outdated: bool = None,
distance: int = None,
latitude: float = None,
longitude: float = None,
timezone: str = None,
serviceTime: str = None,
serviceTimeShort: str = None,
systemId: id = None,
system: TransportationSystem = None,
):
self.id = id
self.groupId = groupId
self.groupColor = groupColor
self.name = name
self.shortName = shortName
self.nameOrig = nameOrig
self.fullname = fullname
self.myid = myid
self.mapApp = mapApp
self.archive = archive
self.goPrefixRouteName = goPrefixRouteName
self.goShowSchedule = goShowSchedule
self.outdated = outdated
self.distance = distance
self.latitude = latitude
self.longitude = longitude
self.serviceTime = serviceTime
self.serviceTimeShort = serviceTimeShort
self.systemId = systemId
self.system = system
# Initialize & Send Request
url = BASE_URL+"/goServices.php?getAlertMessages="+str(paramDigit)
body = {
"systemSelected0" : str(systemSelected),
"amount" : 1,
"routesAmount":0
}
errorMsg = sendApiRequest(url, body)
def getStops(self):
"""
Gets the list of stops for this route and stores it as an argument
"""
stopsForRoute = []
allStops = self.system.getStops()
for stop in allStops:
if \
self.myid in list(stop.routesAndPositions.keys()) or \
self.id in list(stop.routesAndPositions.keys()) or \
self.groupId in list(stop.routesAndPositions.keys()):
stopsForRoute.append(stop)
return(stopsForRoute)
### Stops ###
class Stop:
def __init__(
self,
id: str,
routesAndPositions: dict = None,
systemId: int = None,
name: str = None,
latitude: float = None,
longitude: float = None,
radius: int = None,
system : TransportationSystem = None,
):
if routesAndPositions is None:
routesAndPositions = {}
self.id = id
self.routesAndPositions = routesAndPositions
self.systemId = systemId
self.name = name
self.latitude = latitude
self.longitude = longitude
self.radius = radius
self.system = system
# Handle Request Error
if(errorMsg == None):
return(None)
### System Alerts ###
class SystemAlert:
def __init__(
self,
id: int,
systemId: int = None,
system: TransportationSystem = None,
routeId: int = None,
name: str = None,
html: str = None,
archive: bool = None,
important: bool = None,
dateTimeCreated: str = None,
dateTimeFrom: str = None,
dateTimeTo: str = None,
asPush: bool = None,
gtfs: bool = None,
gtfsAlertCauseId: id = None,
gtfsAlertEffectId: id = None,
gtfsAlertUrl: str = None,
gtfsAlertHeaderText: str = None,
gtfsAlertDescriptionText: str = None,
routeGroupId: int = None,
createdUtc: str = None,
authorId: int = None,
author: str = None,
updated: str = None,
updateAuthorId: int = None,
updateAuthor: str = None,
createdF: str = None,
fromF: str = None,
fromOk: bool = None,
toOk: bool = None,
):
self.id = id
self.systemId = systemId
self.system = system
self.routeId = routeId
self.name = name
self.html = html
self.archive = archive
self.important = important
self.dateTimeCreated = dateTimeCreated
self.dateTimeFrom = dateTimeFrom
self.dateTimeTo = dateTimeTo
self.asPush = asPush
self.gtfs = gtfs
self.gtfsAlertCauseId = gtfsAlertCauseId
self.gtfsAlertEffectId = gtfsAlertEffectId
self.gtfsAlertUrl = gtfsAlertUrl
self.gtfsAlertHeaderText = gtfsAlertHeaderText
self.gtfsAlertDescriptionText = gtfsAlertDescriptionText
self.routeGroupId = routeGroupId
self.createdUtc = createdUtc
self.authorId = authorId
self.author = author
self.updated = updated
self.updateAuthorId = updateAuthorId
self.updateAuthor = updateAuthor
self.createdF = createdF
self.fromF = fromF
self.fromOk = fromOk
self.toOk = toOk
return(errorMsg)
def getBuses(
@@ -156,46 +611,8 @@ def getBuses(
return(buses)
def getSystems(
paramDigit = 2,
sortMode = 1,
deviceId = 43647468
):
"""
Gets all system alerts for the selected system.
=========
systemSelected: system from which to get content
paramDigit:
0: Error
>=1: Valid
"""
# Initialize & Send Request
url = f"{BASE_URL}/mapGetData.php?getSystems={paramDigit}&sortMode={sortMode}&deviceId={deviceId}&credentials=1"
systems = sendApiRequest(url, None)
# Handle Request Error
if(systems == None):
return(None)
return(systems)
def printAllSystemsMd(
paramDigit = 2,
sortMode = 1,
deviceId = 43647468,
includeHtml = True
):
systems = getSystems(paramDigit,sortMode,deviceId)
for system in systems["all"]:
print(f"- {system['fullname']}{'<br/>' if includeHtml else ''}")
### Live Timings ###
## Not Yet Supported! ##
# Launch WebSocket
def launchWS():
+2 -2
View File
@@ -8,7 +8,7 @@ with open("requirements.txt", "r") as fh:
setup(
name='PassioGo',
version="0.1.2",
version="0.2.0",
description="An unofficial API for Passio Go",
long_description=long_description,
long_description_content_type='text/markdown',
@@ -21,7 +21,7 @@ setup(
project_urls = {
'Documentation': 'https://passiogo.readthedocs.io/',
'GitHub': 'https://github.com/athuler/PassioGo',
'Support':'https://github.com/sponsors/athuler',
'Sponsor':'https://github.com/sponsors/athuler',
'Changelog':'https://github.com/athuler/PassioGo/blob/main/CHANGELOG.md',
},
)
+15 -9
View File
@@ -1,19 +1,25 @@
import passiogo
def test_getAllSystems():
passiogo.getSystems
def test_printAllSystems():
passiogo.printAllSystemsMd()
def test_getSystemFromId():
global testSystem
testSystem = passiogo.getSystemFromID(1068)
def test_getAllRoutes():
passiogo.getAllRoutes(1068)
testSystem.getRoutes()
def test_getAllStops():
passiogo.getAllStops(1068)
testSystem.getStops()
def test_getSystemAlerts():
passiogo.getSystemAlerts(1068)
testSystem.getSystemAlerts()
def test_getBuses():
passiogo.getBuses(1068)
def test_getSystems():
passiogo.getSystems()
def test_printAllSystems():
passiogo.printAllSystemsMd()