hasl-sensor / integration

Swedish Public Transport Sensor (HASL). Formerly named HomeAssistant SL Sensor
https://hasl.sorlov.com
Apache License 2.0
34 stars 7 forks source link

New Data format with more information in Travel Planner #28

Closed clearminds closed 2 years ago

pep8speaks commented 2 years ago

Hello @clearminds! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 223:80: E501 line too long (111 > 79 characters) Line 243:80: E501 line too long (86 > 79 characters) Line 245:80: E501 line too long (105 > 79 characters) Line 246:80: E501 line too long (91 > 79 characters) Line 247:80: E501 line too long (118 > 79 characters) Line 254:80: E501 line too long (99 > 79 characters) Line 255:80: E501 line too long (82 > 79 characters) Line 256:80: E501 line too long (89 > 79 characters) Line 258:80: E501 line too long (120 > 79 characters) Line 259:80: E501 line too long (101 > 79 characters) Line 260:80: E501 line too long (133 > 79 characters) Line 263:80: E501 line too long (86 > 79 characters) Line 264:80: E501 line too long (86 > 79 characters) Line 265:80: E501 line too long (84 > 79 characters) Line 266:80: E501 line too long (84 > 79 characters) Line 267:80: E501 line too long (109 > 79 characters) Line 268:80: E501 line too long (92 > 79 characters) Line 269:80: E501 line too long (99 > 79 characters) Line 276:80: E501 line too long (82 > 79 characters) Line 277:80: E501 line too long (82 > 79 characters) Line 280:80: E501 line too long (87 > 79 characters) Line 281:80: E501 line too long (106 > 79 characters) Line 285:80: E501 line too long (87 > 79 characters) Line 286:80: E501 line too long (104 > 79 characters) Line 300:80: E501 line too long (92 > 79 characters) Line 301:80: E501 line too long (83 > 79 characters) Line 304:1: W293 blank line contains whitespace Line 306:80: E501 line too long (84 > 79 characters) Line 309:80: E501 line too long (95 > 79 characters) Line 312:80: E501 line too long (97 > 79 characters) Line 321:38: E111 indentation is not a multiple of four Line 321:38: E117 over-indented Line 323:38: E111 indentation is not a multiple of four Line 323:38: E117 over-indented Line 325:38: E111 indentation is not a multiple of four Line 325:38: E117 over-indented Line 327:33: E265 block comment should start with '# ' Line 346:80: E501 line too long (95 > 79 characters) Line 376:80: E501 line too long (80 > 79 characters) Line 380:80: E501 line too long (90 > 79 characters) Line 383:80: E501 line too long (127 > 79 characters) Line 500:80: E501 line too long (86 > 79 characters) Line 535:80: E501 line too long (86 > 79 characters) Line 630:80: E501 line too long (81 > 79 characters)

DSorlov commented 2 years ago

This looks very promising. However there are some changes I would like to have implemented.

According to current dev there is some handling (and ignoring) of walking results in the trip planner. So; walking is not counted as a transfer (as it is at SL), and also when destination and origin it is the stops.

See line 275 of haslworker/init.py for inspration on possible solution.

#Add shortcuts to info in the first trip if it exists
firstLegFirstTrip = next((x for x in newdata['trips'][0]['legs'] if x["category"] != "WALK"), [])
lastLegLastTrip = next((x for x in reversed(newdata['trips'][0]['legs']) if x["category"] != "WALK"), [])
newdata['transfers'] = sum(p["category"] != "WALK" for p in newdata['trips'][0]['legs'])-1 or 0

More handling is also on line 240. There are some changes that you did not capture from dev in regards to the attributes returned also. Looking very promising and will merge if the above changes are completed.

DSorlov commented 2 years ago

Will now close due to inactivity and new conflicts.