Thread: [SailfishOS] Pan Transit
View Single Post
otsaloma's Avatar
Posts: 141 | Thanked: 1,530 times | Joined on May 2011 @ Finland
#8
Originally Posted by bomo View Post
Is there anything in the code (apart from requests) that I need to change before it can be included on your builds?
Please adhere to PEP8, the Python style guide and the existing code base style. Four spaces for indentation, max. 79 characters per line, double quotes for strings. After that you can file a pull request on GitHub, once I see the final code, there might some details to iron out before merging, but it's better to discuss that on GitHub, where I can comment on parts of the code.

Originally Posted by bomo View Post
For find_nearby I don't have an implementation because I don't know how to get it from the API. Would it be possible to remove this option depending on the selected provider ?
That's all right, just have find_nearby_stops return a blank list. I'm unlikely to conditionally remove it from the UI, because I think almost all providers do support a nearby search.

Originally Posted by bomo View Post
I am currently trying to get rid of request but I'm (again) struggling with pan.http.post
Why are you using post? Use get!

https://developer.mozilla.org/en-US/...b/HTTP/Methods

What you likely want is

Code:
# For API endpoints that return JSON:
result = pan.http.get_json(url)

# For API endpoints that return text:
result = pan.http.get(url, encoding="utf_8")
Please take a look at the TfL provider code for an example. The essential parts of the code are very brief and should be understandable. It also shows how to constuct URLs (format_url) and how to quote search strings (urllib.parse.quote).

https://github.com/otsaloma/pan-tran...oviders/tfl.py
 

The Following 2 Users Say Thank You to otsaloma For This Useful Post: