twobells 0.2.0__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. {twobells-0.2.0/src/twobells.egg-info → twobells-0.2.2}/PKG-INFO +4 -4
  2. {twobells-0.2.0 → twobells-0.2.2}/README.md +3 -3
  3. {twobells-0.2.0 → twobells-0.2.2}/pyproject.toml +1 -1
  4. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/net.py +110 -3
  5. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard/config.py +2 -2
  6. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard/enrich.py +25 -14
  7. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/settings/schema.py +1 -1
  8. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/keytest.py +2 -0
  9. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/livebus.py +60 -33
  10. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/timetable/build.py +40 -28
  11. {twobells-0.2.0 → twobells-0.2.2/src/twobells.egg-info}/PKG-INFO +4 -4
  12. {twobells-0.2.0 → twobells-0.2.2}/LICENSE +0 -0
  13. {twobells-0.2.0 → twobells-0.2.2}/setup.cfg +0 -0
  14. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/__init__.py +0 -0
  15. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/__main__.py +0 -0
  16. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/__init__.py +0 -0
  17. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/app.py +0 -0
  18. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/displays/__init__.py +0 -0
  19. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/displays/display.py +0 -0
  20. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/displays/screen.py +0 -0
  21. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/displays/waveshare.py +0 -0
  22. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/dotfont.py +0 -0
  23. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/flaps.py +0 -0
  24. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/fonts/Inter-ExtraBold.ttf +0 -0
  25. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/fonts/Inter-Regular.ttf +0 -0
  26. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/fonts/LICENSE +0 -0
  27. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/fonts/SHA256SUMS +0 -0
  28. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/panel.py +0 -0
  29. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/platformclock.py +0 -0
  30. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/positions.py +0 -0
  31. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/render.py +0 -0
  32. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/route.py +0 -0
  33. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/scroll.py +0 -0
  34. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/sign.py +0 -0
  35. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/speaker.py +0 -0
  36. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/splitflap.py +0 -0
  37. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/state.py +0 -0
  38. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/tft.py +0 -0
  39. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/themes.py +0 -0
  40. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/board/view.py +0 -0
  41. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/cli/__init__.py +0 -0
  42. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/cli/common.py +0 -0
  43. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/cli/dev.py +0 -0
  44. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/cli/main.py +0 -0
  45. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/cli/run.py +0 -0
  46. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/cli/serve.py +0 -0
  47. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/cli/setup.py +0 -0
  48. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/cli/timetable.py +0 -0
  49. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/__init__.py +0 -0
  50. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/announce.py +0 -0
  51. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/budget.py +0 -0
  52. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/calling.py +0 -0
  53. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/errors.py +0 -0
  54. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/files.py +0 -0
  55. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/model.py +0 -0
  56. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/osgb.py +0 -0
  57. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/polling.py +0 -0
  58. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/safexml.py +0 -0
  59. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/walk.py +0 -0
  60. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/core/words.py +0 -0
  61. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard/__init__.py +0 -0
  62. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard/area.py +0 -0
  63. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard/collector.py +0 -0
  64. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard/history.py +0 -0
  65. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard/performance.py +0 -0
  66. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard/repay.py +0 -0
  67. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard/snapshot.py +0 -0
  68. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/alerts.js +0 -0
  69. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/api.js +0 -0
  70. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/app.css +0 -0
  71. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/area.js +0 -0
  72. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/board.js +0 -0
  73. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/disruptions.js +0 -0
  74. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/dom.js +0 -0
  75. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/extras.js +0 -0
  76. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/flap.js +0 -0
  77. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/fonts/DepartureboardDots.woff2 +0 -0
  78. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/fonts/LICENSE +0 -0
  79. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/fonts/SHA256SUMS +0 -0
  80. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/header.js +0 -0
  81. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/hero.js +0 -0
  82. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/history.js +0 -0
  83. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/icons/apple-touch-icon.png +0 -0
  84. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/icons/icon-192.png +0 -0
  85. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/icons/icon-512.png +0 -0
  86. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/icons/icon.svg +0 -0
  87. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/icons.js +0 -0
  88. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/index.html +0 -0
  89. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/kiosk.js +0 -0
  90. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/live.js +0 -0
  91. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/look.js +0 -0
  92. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/main.js +0 -0
  93. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/manifest.webmanifest +0 -0
  94. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/map.js +0 -0
  95. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/measures.js +0 -0
  96. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/pa.js +0 -0
  97. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/performance.html +0 -0
  98. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/performance.js +0 -0
  99. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/platformclock.js +0 -0
  100. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/sheet.js +0 -0
  101. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/show.js +0 -0
  102. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/strip.js +0 -0
  103. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/theme.js +0 -0
  104. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/time.js +0 -0
  105. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/train.js +0 -0
  106. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/vendor/inter-4.1/InterVariable.woff2 +0 -0
  107. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/vendor/inter-4.1/LICENSE +0 -0
  108. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/vendor/inter-4.1/SHA256SUMS +0 -0
  109. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/vendor/leaflet-1.9.4/LICENSE +0 -0
  110. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/vendor/leaflet-1.9.4/SHA256SUMS +0 -0
  111. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/vendor/leaflet-1.9.4/leaflet-src.esm.js +0 -0
  112. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/vendor/leaflet-1.9.4/leaflet.css +0 -0
  113. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/dashboard_static/weather.js +0 -0
  114. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/data/gb_stations.csv +0 -0
  115. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/data/naptan_area_grid.csv +0 -0
  116. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/emulator/__init__.py +0 -0
  117. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/emulator/emulation.py +0 -0
  118. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/emulator/emulator.html +0 -0
  119. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/emulator/fake.py +0 -0
  120. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/emulator/server.py +0 -0
  121. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/fetch/__init__.py +0 -0
  122. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/fetch/handoff.py +0 -0
  123. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/fetch/service.py +0 -0
  124. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/settings/__init__.py +0 -0
  125. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/settings/config.py +0 -0
  126. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/settings/installs.py +0 -0
  127. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/settings/keyresults.py +0 -0
  128. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/settings/overlay.py +0 -0
  129. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/settings/show.py +0 -0
  130. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/settings/store.py +0 -0
  131. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/__init__.py +0 -0
  132. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/api.py +0 -0
  133. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/discover.py +0 -0
  134. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/lookups.py +0 -0
  135. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/spool/__init__.py +0 -0
  136. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/spool/checks.py +0 -0
  137. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/spool/folder.py +0 -0
  138. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/spool/runner.py +0 -0
  139. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/setup/spool/worker.py +0 -0
  140. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/__init__.py +0 -0
  141. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/bods.py +0 -0
  142. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/bodsbus.py +0 -0
  143. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/darwin.py +0 -0
  144. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/disruptions.py +0 -0
  145. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/holidays.py +0 -0
  146. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/lastbus.py +0 -0
  147. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/transportapi.py +0 -0
  148. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/sources/weather.py +0 -0
  149. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/timetable/__init__.py +0 -0
  150. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/timetable/model.py +0 -0
  151. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/timetable/roads.py +0 -0
  152. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/timetable/routesetup.py +0 -0
  153. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/version.py +0 -0
  154. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/__init__.py +0 -0
  155. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/auth.py +0 -0
  156. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/formpages.py +0 -0
  157. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/groupform.py +0 -0
  158. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/icons.py +0 -0
  159. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/keyspage.py +0 -0
  160. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/keystate.py +0 -0
  161. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/netguard.py +0 -0
  162. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/overview.py +0 -0
  163. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/places.py +0 -0
  164. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/server.py +0 -0
  165. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/settings.js +0 -0
  166. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/settingsite.py +0 -0
  167. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/status.py +0 -0
  168. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/web.css +0 -0
  169. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/web/windowrows.py +0 -0
  170. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/api.js +0 -0
  171. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/finish.js +0 -0
  172. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/home.js +0 -0
  173. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/index.html +0 -0
  174. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/keys.js +0 -0
  175. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/maps.js +0 -0
  176. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/presets.js +0 -0
  177. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/roads.js +0 -0
  178. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/say.js +0 -0
  179. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/state.js +0 -0
  180. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/station.js +0 -0
  181. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/steps.js +0 -0
  182. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/stops.js +0 -0
  183. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/views.js +0 -0
  184. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/walk.js +0 -0
  185. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/wizard.css +0 -0
  186. {twobells-0.2.0 → twobells-0.2.2}/src/twobells/wizard_static/wizard.js +0 -0
  187. {twobells-0.2.0 → twobells-0.2.2}/src/twobells.egg-info/SOURCES.txt +0 -0
  188. {twobells-0.2.0 → twobells-0.2.2}/src/twobells.egg-info/dependency_links.txt +0 -0
  189. {twobells-0.2.0 → twobells-0.2.2}/src/twobells.egg-info/entry_points.txt +0 -0
  190. {twobells-0.2.0 → twobells-0.2.2}/src/twobells.egg-info/requires.txt +0 -0
  191. {twobells-0.2.0 → twobells-0.2.2}/src/twobells.egg-info/top_level.txt +0 -0
  192. {twobells-0.2.0 → twobells-0.2.2}/tests/test_deploy.py +0 -0
  193. {twobells-0.2.0 → twobells-0.2.2}/tests/test_docs.py +0 -0
  194. {twobells-0.2.0 → twobells-0.2.2}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: twobells
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Two Bells: know when to leave. Train and bus departures for Great Britain, on an e-paper or HDMI board on a Raspberry Pi and on a web dashboard, installed on a Pi, in Docker or on a desktop
5
5
  Author: Albert Cornelissen
6
6
  License-Expression: MIT
@@ -47,7 +47,7 @@ Dynamic: license-file
47
47
  One install is one app with two views of the same departures:
48
48
 
49
49
  - **The board:** a Raspberry Pi with a four-colour Inky pHAT (250x122). The app also draws for a Waveshare 10.85" e-Paper (G) (1360x480), a Waveshare 7.9" HDMI screen (1280x400, on its side) and an 11.3" HDMI bar screen (1920x440); those are tested in software but not yet on the hardware.
50
- - **The dashboard:** a web page for a phone or computer at home, with the next 10 trains and buses, calling points, bus strips and maps, the weather, disruptions and punctuality history.
50
+ - **The dashboard:** a web page for a phone or computer at home, with the next 10 trains and buses, calling points and coaches, bus strips and maps, the weather, disruptions, punctuality history, a Performance page with Delay Repay, and station announcements.
51
51
 
52
52
  A Pi can run either view or both; Docker and a desktop run the dashboard. Each install has one settings site, at `/settings` on port 8090, with one password and a setup wizard that finds your station, stops, walk times and bus companies from your postcode. The examples use Glossop, with trains to Manchester and buses from two nearby stops (`examples/glossop.toml`).
53
53
 
@@ -79,7 +79,7 @@ Where there is room, the line runs across the page with each train placed on it:
79
79
 
80
80
  Light, dark, the amber Dot matrix look, the white and yellow TFT look or the Split-flap look, at any size from a phone to a wall tablet (`/?kiosk`):
81
81
 
82
- ![The dashboard on a phone in the light look, the dark look and the amber Dot matrix look](docs/images/dashboard-looks.png)
82
+ ![The dashboard on a phone at 07:03, Leave now for the 07:09 341 bus: the Standard look, light and dark, and the amber Dot matrix look](docs/images/dashboard-looks.png)
83
83
 
84
84
  ## The board
85
85
 
@@ -91,7 +91,7 @@ On the 10.85" e-paper there is room for platforms (as the app draws it; not yet
91
91
 
92
92
  ![The station board look on the 10.85 inch e-paper](docs/images/epaper-10in85.png)
93
93
 
94
- An HDMI screen redraws every second, with a running clock and countdowns, and a page showing where your next bus is (again as the app draws it, not yet tried on a real screen):
94
+ An HDMI screen redraws every second, with a running clock and countdowns, two more looks (`tft`, white and yellow on black, and `flap`, a split-flap board whose tiles turn), and if you want them the first train's calling points, a platform clock page and station announcements through a speaker. It also has a page showing where your next bus is (again as the app draws it, not yet tried on a real screen):
95
95
 
96
96
  ![The bus position page: the 341 to Hyde three stops from Henry Street, leave in 3 min](docs/images/screen-bus.png)
97
97
 
@@ -13,7 +13,7 @@
13
13
  One install is one app with two views of the same departures:
14
14
 
15
15
  - **The board:** a Raspberry Pi with a four-colour Inky pHAT (250x122). The app also draws for a Waveshare 10.85" e-Paper (G) (1360x480), a Waveshare 7.9" HDMI screen (1280x400, on its side) and an 11.3" HDMI bar screen (1920x440); those are tested in software but not yet on the hardware.
16
- - **The dashboard:** a web page for a phone or computer at home, with the next 10 trains and buses, calling points, bus strips and maps, the weather, disruptions and punctuality history.
16
+ - **The dashboard:** a web page for a phone or computer at home, with the next 10 trains and buses, calling points and coaches, bus strips and maps, the weather, disruptions, punctuality history, a Performance page with Delay Repay, and station announcements.
17
17
 
18
18
  A Pi can run either view or both; Docker and a desktop run the dashboard. Each install has one settings site, at `/settings` on port 8090, with one password and a setup wizard that finds your station, stops, walk times and bus companies from your postcode. The examples use Glossop, with trains to Manchester and buses from two nearby stops (`examples/glossop.toml`).
19
19
 
@@ -45,7 +45,7 @@ Where there is room, the line runs across the page with each train placed on it:
45
45
 
46
46
  Light, dark, the amber Dot matrix look, the white and yellow TFT look or the Split-flap look, at any size from a phone to a wall tablet (`/?kiosk`):
47
47
 
48
- ![The dashboard on a phone in the light look, the dark look and the amber Dot matrix look](docs/images/dashboard-looks.png)
48
+ ![The dashboard on a phone at 07:03, Leave now for the 07:09 341 bus: the Standard look, light and dark, and the amber Dot matrix look](docs/images/dashboard-looks.png)
49
49
 
50
50
  ## The board
51
51
 
@@ -57,7 +57,7 @@ On the 10.85" e-paper there is room for platforms (as the app draws it; not yet
57
57
 
58
58
  ![The station board look on the 10.85 inch e-paper](docs/images/epaper-10in85.png)
59
59
 
60
- An HDMI screen redraws every second, with a running clock and countdowns, and a page showing where your next bus is (again as the app draws it, not yet tried on a real screen):
60
+ An HDMI screen redraws every second, with a running clock and countdowns, two more looks (`tft`, white and yellow on black, and `flap`, a split-flap board whose tiles turn), and if you want them the first train's calling points, a platform clock page and station announcements through a speaker. It also has a page showing where your next bus is (again as the app draws it, not yet tried on a real screen):
61
61
 
62
62
  ![The bus position page: the 341 to Hyde three stops from Henry Street, leave in 3 min](docs/images/screen-bus.png)
63
63
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "twobells"
7
- version = "0.2.0"
7
+ version = "0.2.2"
8
8
  description = "Two Bells: know when to leave. Train and bus departures for Great Britain, on an e-paper or HDMI board on a Raspberry Pi and on a web dashboard, installed on a Pi, in Docker or on a desktop"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -5,6 +5,7 @@ from __future__ import annotations
5
5
  import io
6
6
  import json
7
7
  import time
8
+ import zlib
8
9
  from collections.abc import Iterator, Mapping
9
10
  from functools import partial
10
11
  from http.client import HTTPConnection, HTTPSConnection
@@ -12,6 +13,7 @@ from urllib.error import HTTPError
12
13
  from urllib.parse import urlsplit
13
14
  from urllib.request import (
14
15
  AbstractHTTPHandler,
16
+ BaseHandler,
15
17
  HTTPDefaultErrorHandler,
16
18
  HTTPErrorProcessor,
17
19
  HTTPHandler,
@@ -164,13 +166,118 @@ class _HTTPSHandler(_Deadlines, HTTPSHandler):
164
166
  pass
165
167
 
166
168
 
169
+ # Content-Encoding. Nothing here asks for a compressed answer (http.client
170
+ # sends "Accept-Encoding: identity"), but a service may send one anyway: the
171
+ # Rail Data Marketplace gzips its Knowledgebase incidents. Every answer is
172
+ # read decoded, as it arrives, so a caller's cap on what it reads is a cap on
173
+ # the decoded size: a small answer that would inflate to gigabytes (a gzip
174
+ # bomb) is never inflated past what the caller asked for.
175
+
176
+ _GZIP = 16 + zlib.MAX_WBITS # zlib's wbits for gzip's header and trailer
177
+ _DECODERS = {"gzip": _GZIP, "x-gzip": _GZIP, "deflate": zlib.MAX_WBITS} # deflate is zlib's format
178
+ _RAW_CHUNK = 1 << 16 # compressed bytes read at a time
179
+ _BROKEN = "The service sent a compressed answer that is broken or cut short"
180
+
181
+
182
+ class BadEncoding(ValueError):
183
+ """The answer was in a Content-Encoding this app doesn't read, or its
184
+ compressed body was broken."""
185
+
186
+
187
+ def _wbits(content_encoding: str) -> int | None:
188
+ """zlib's wbits for a Content-Encoding header's value; None for an
189
+ answer sent as it is. BadEncoding for anything else, a chain of
190
+ encodings included."""
191
+ codings = [part.strip().lower() for part in content_encoding.split(",")]
192
+ codings = [coding for coding in codings if coding and coding != "identity"]
193
+ if not codings:
194
+ return None
195
+ if len(codings) == 1 and codings[0] in _DECODERS:
196
+ return _DECODERS[codings[0]]
197
+ raise BadEncoding("The service sent its answer in a form this app can't read "
198
+ "(a Content-Encoding other than gzip or deflate)")
199
+
200
+
201
+ class _Decoded:
202
+ """A response whose body is read decoded. read(size) inflates no more
203
+ than `size` bytes however small the compressed answer, and reads the
204
+ response a chunk at a time, so its deadline still holds. Everything else
205
+ (status, headers, closing) is the response's own."""
206
+
207
+ def __init__(self, response, wbits: int):
208
+ self._response = response
209
+ self._wbits = wbits
210
+ self._inflate = zlib.decompressobj(wbits)
211
+ self._pending = b"" # read from the response, not yet inflated
212
+
213
+ def __getattr__(self, name: str):
214
+ return getattr(self._response, name)
215
+
216
+ def __enter__(self):
217
+ return self
218
+
219
+ def __exit__(self, *exc) -> None:
220
+ self._response.close()
221
+
222
+ def read(self, size: int = -1) -> bytes:
223
+ if size is None or size < 0:
224
+ raise ValueError("A compressed answer is read a size at a time")
225
+ decoded = bytearray()
226
+ while len(decoded) < size:
227
+ ended = False
228
+ if not self._pending:
229
+ self._pending = self._response.read(_RAW_CHUNK)
230
+ ended = not self._pending
231
+ if self._inflate.eof:
232
+ if ended:
233
+ break
234
+ if self._wbits != _GZIP: # deflate is one stream; gzip may be several, one after another
235
+ raise BadEncoding(_BROKEN)
236
+ self._inflate = zlib.decompressobj(self._wbits)
237
+ try:
238
+ data = self._inflate.decompress(self._pending, size - len(decoded))
239
+ except zlib.error:
240
+ raise BadEncoding(_BROKEN) from None
241
+ self._pending = self._inflate.unused_data if self._inflate.eof else self._inflate.unconsumed_tail
242
+ decoded += data
243
+ if ended and not data and not self._inflate.eof:
244
+ raise BadEncoding(_BROKEN) # the answer stopped part way through
245
+ return bytes(decoded)
246
+
247
+
248
+ class _ContentDecoding(BaseHandler):
249
+ """Gives every answer as its decoded body, but for a redirect, whose body
250
+ urllib reads whole and throws away. It comes before HTTPErrorProcessor,
251
+ so an error's body, which the key test reads for clues, is decoded too;
252
+ an error in an encoding this app can't read keeps its status, its body
253
+ as sent."""
254
+
255
+ handler_order = 900 # HTTPErrorProcessor's is 1000
256
+
257
+ def http_response(self, request, response):
258
+ code = response.code
259
+ if 300 <= code < 400:
260
+ return response
261
+ try:
262
+ wbits = _wbits(", ".join(response.headers.get_all("Content-Encoding") or []))
263
+ except BadEncoding:
264
+ if code >= 400:
265
+ return response
266
+ response.close()
267
+ raise
268
+ return response if wbits is None else _Decoded(response, wbits)
269
+
270
+ https_response = http_response
271
+
272
+
167
273
  def _build_opener() -> OpenerDirector:
168
274
  """urllib's build_opener always adds file:, ftp: and data: handlers; this
169
275
  opener has only http and https, so any other address fails as an
170
- unknown url type, wherever it came from (a redirect included)."""
276
+ unknown url type, wherever it came from (a redirect included). Every
277
+ answer comes decoded from its Content-Encoding."""
171
278
  opener = OpenerDirector()
172
279
  for handler in (UnknownHandler, HTTPDefaultErrorHandler, SafeRedirects, _HTTPHandler, _HTTPSHandler,
173
- HTTPErrorProcessor):
280
+ _ContentDecoding, HTTPErrorProcessor):
174
281
  opener.add_handler(handler())
175
282
  return opener
176
283
 
@@ -242,7 +349,7 @@ def get_bytes(url: str, max_bytes: int, timeout: float = 15.0, headers: dict | N
242
349
  with urlopen(request, timeout=timeout) as response:
243
350
  body = response.read(max_bytes + 1)
244
351
  if len(body) > max_bytes:
245
- raise ValueError(f"Response larger than {max_bytes} bytes")
352
+ raise TooLarge(f"Response larger than {max_bytes} bytes")
246
353
  return body
247
354
 
248
355
 
@@ -93,7 +93,7 @@ class DashboardOptions:
93
93
 
94
94
  state_dir: str | None = None
95
95
  train_rows: int = 10
96
- bus_rows: int = 10
96
+ bus_rows: int = 15 # about half an hour across five stops
97
97
  train_interval_seconds: int = 60
98
98
  bus_interval_seconds: int = 30
99
99
  weather_interval_minutes: int = 30
@@ -174,7 +174,7 @@ def dashboard_options(data: dict) -> DashboardOptions:
174
174
  return DashboardOptions(
175
175
  state_dir=state_dir,
176
176
  train_rows=_ranged(section, "train_rows", 10, 1, _MAX_ROWS),
177
- bus_rows=_ranged(section, "bus_rows", 10, 1, _MAX_ROWS),
177
+ bus_rows=_ranged(section, "bus_rows", 15, 1, _MAX_ROWS),
178
178
  train_interval_seconds=_whole(section, "train_interval_seconds", 60, _WHERE, least=30),
179
179
  bus_interval_seconds=_whole(section, "bus_interval_seconds", 30, _WHERE, least=15),
180
180
  weather_interval_minutes=_whole(section, "weather_interval_minutes", 30, _WHERE, least=10),
@@ -20,7 +20,9 @@ block, or else guessed by line) is shown as a line of its own ("Bus
20
20
  arriving from Ashton, 4 min late (due 23:29)"), with the facts from its
21
21
  tracker: where it is and how late. Either way the departure is live, and
22
22
  livebus carries the bus's lateness on to the departure's time; `followed`
23
- tells the API which it was.
23
+ tells the API which it was. The same journey's later stops of yours have
24
+ the same bus, named arriving where the journey starts ("Bus arriving at
25
+ Henry Street from Ashton, ...").
24
26
 
25
27
  Ghost buses. A bus due within GHOST_WITHIN with no live bus placed on its
26
28
  journey is flagged, since trackers usually show up well before then. Not
@@ -139,8 +141,10 @@ def _origin(placed: LiveJourney, positions: dict[str, StopPosition]) -> str | No
139
141
  return _clean(placed.vehicle.origin_name)
140
142
 
141
143
 
142
- def _where(placed: LiveJourney, stop: str, positions: dict[str, StopPosition]) -> str:
143
- """Where the inbound bus is, as the route strip says it: "4 stops away"."""
144
+ def _where(placed: LiveJourney, live: LiveDeparture, positions: dict[str, StopPosition]) -> str:
145
+ """Where the inbound bus is, as the route strip says it: "4 stops away"
146
+ from the end of its journey, then "At your stop", or, for a later stop
147
+ of the departure's journey, at the stop it is in at ("At Henry Street")."""
144
148
  calls = placed.journey.calls
145
149
  away = (len(calls) - 1) - math.floor(placed.progress.at + 0.02)
146
150
  if away == 1:
@@ -148,35 +152,42 @@ def _where(placed: LiveJourney, stop: str, positions: dict[str, StopPosition]) -
148
152
  if away > 1:
149
153
  return f"{away} stops away"
150
154
  end = calls[-1].atco
151
- if end == stop or end not in positions:
155
+ if live.call_index == 0 and (end == live.journey.origin.atco or end not in positions):
152
156
  return "At your stop"
153
- return f"At {positions[end].name}"
157
+ for atco in (end, live.journey.origin.atco):
158
+ if atco in positions:
159
+ return f"At {positions[atco].name}"
160
+ return "Waiting to start"
154
161
 
155
162
 
156
163
  def inbound(live: LiveDeparture, positions: dict[str, StopPosition]) -> dict | None:
157
- """The bus coming in to work a departure that starts at your stop, as
158
- livebus found it, or None (see the module's notes). `followed` says
159
- whether it was followed by the timetable's block rather than guessed by
160
- line; either makes the departure live."""
164
+ """The bus coming in to work a departure that starts at your stop, or a
165
+ later stop of yours on the same journey, as livebus found it, or None
166
+ (see the module's notes). `followed` says whether it was followed by
167
+ the timetable's block rather than guessed by line; either makes the
168
+ departure live."""
161
169
  coming = live.inbound
162
170
  if coming is None:
163
171
  return None
164
172
  origin = _origin(coming.bus, positions)
165
173
  due = coming.arrives.strftime("%H:%M")
174
+ start = positions.get(live.journey.origin.atco) if live.call_index > 0 else None
166
175
  return {
167
176
  "from": origin,
168
177
  "due": due,
169
178
  "late_min": coming.late,
170
- "where": _where(coming.bus, live.journey.origin.atco, positions),
171
- "text": inbound_text(origin, coming.late, due),
179
+ "where": _where(coming.bus, live, positions),
180
+ "text": inbound_text(origin, coming.late, due, start.name if start is not None else None),
172
181
  "followed": coming.followed,
173
182
  }
174
183
 
175
184
 
176
- def inbound_text(origin: str | None, late: int, due: str) -> str:
185
+ def inbound_text(origin: str | None, late: int, due: str, start: str | None = None) -> str:
177
186
  """The inbound bus in words for the row: "Bus arriving from Ashton, 4 min
178
- late (due 23:29)". Its own lateness and time, never a time for the departure."""
179
- coming = f"Bus arriving from {origin}" if origin else "Bus arriving"
187
+ late (due 23:29)". Its own lateness and time, never a time for the
188
+ departure. `start` names the stop it arrives at, the journey's first, for
189
+ a row at a later stop: "Bus arriving at Henry Street from Ashton, ..."."""
190
+ coming = "Bus arriving" + (f" at {start}" if start else "") + (f" from {origin}" if origin else "")
180
191
  return f"{coming}, {f'{late} min late' if late else 'on time'} (due {due})"
181
192
 
182
193
 
@@ -529,7 +529,7 @@ def fields(display: str = "inky", theme: str = "sign") -> tuple[Field, ...]:
529
529
  "number", hint=_LISTED, default=10, needs="train", page="dashboard", heading="Departures",
530
530
  width="2"),
531
531
  Field("dashboard_bus_rows", "dashboard", "dashboard", "bus_rows", "Most buses listed", number(1, 20),
532
- "number", hint=_LISTED, default=10, needs="bus", page="dashboard", heading="Departures",
532
+ "number", hint=_LISTED, default=15, needs="bus", page="dashboard", heading="Departures",
533
533
  width="2"),
534
534
  Field("row_strips", "dashboard", "dashboard", "row_strips", "Position strips in each row", on_off, "radios",
535
535
  hint="A small drawing of the stops in each departure row, with the train or bus where it is, while "
@@ -134,6 +134,8 @@ def _call(fetch: Callable[[str, Mapping[str, str]], _Body], url: str, headers: M
134
134
  return fetch(url, headers)
135
135
  except HTTPError as error:
136
136
  raise _Outcome(_refused(error, service)) from None
137
+ except net.BadEncoding: # compressed in a way this can't read, or broken
138
+ raise _Outcome(_unreadable(service)) from None
137
139
  except TimeoutError: # socket.timeout too
138
140
  raise _Outcome(_down(service, _SLOW)) from None
139
141
  except URLError as error:
@@ -14,10 +14,14 @@ bus. If that bus is placed (matched to that journey, or sending the same
14
14
  block as its BlockRef), the departure is live too, marked inbound ("Bus on
15
15
  its way, due in 6 min"): expected when that bus gets in plus TURNAROUND,
16
16
  never before its time; once in, on time, or, that gone, any minute. Only
17
- a departure from the journey's first stop is followed in: the bus's words
18
- count down to there. A bus still in INBOUND_WINDOW after the departure's
19
- time, still on the journey before, has laid over or gone out of service:
20
- it is let go, and the departure goes as one with no bus seen would. The block is a hint, never trusted blindly: the
17
+ a journey whose first stop is yours is followed in, and the same bus goes
18
+ with it to its later stops of yours until it is placed on the journey:
19
+ expected at each the timetable's run time from the first stop after it
20
+ is expected to leave there, so never before its time either. Its words
21
+ count down to the bus getting to your stop. A bus still in INBOUND_WINDOW
22
+ after the time at the first stop, still on the journey before, has laid
23
+ over or gone out of service: it is let go at every stop, and the departure
24
+ goes as one with no bus seen would. The block is a hint, never trusted blindly: the
21
25
  journey before must be the same operator's, on the same service day, the
22
26
  one just before it in the block, and end at the departure's first stop, or
23
27
  within NEAR_M of it, up to INBOUND_WINDOW before it leaves. If that bus
@@ -301,8 +305,9 @@ class LiveJourney:
301
305
 
302
306
  @dataclass(frozen=True)
303
307
  class Inbound:
304
- """The bus coming in to work a departure that starts at your stop, placed
305
- on the journey before (see the module's notes)."""
308
+ """The bus coming in to work a journey that starts at your stop, placed
309
+ on the journey before (see the module's notes). Its times are at the
310
+ end of the journey before, the departure's first stop."""
306
311
 
307
312
  bus: LiveJourney
308
313
  # By the block: the same bus. False for a guess by line. Either makes the
@@ -345,8 +350,8 @@ class LiveDeparture:
345
350
  expected: datetime # leaves plus any lateness, board-local without a zone
346
351
  progress: Progress | None # None when no bus was placed on the journey
347
352
  vehicle: Vehicle | None # the bus behind progress
348
- # The bus coming in to work it, for a departure from its journey's first
349
- # stop with no bus placed on that journey (see the module's notes).
353
+ # The bus coming in to work it, for a journey starting at your stop with
354
+ # no bus placed on it, at that stop and its later ones (see the module's notes).
350
355
  inbound: Inbound | None = None
351
356
 
352
357
  @property
@@ -437,7 +442,8 @@ def live_board(
437
442
  with its delay and stays on the board however late; one that has passed
438
443
  your stop is dropped. A departure whose bus is followed in (see the
439
444
  module's notes) is shown as late as that bus makes it, until a minute
440
- after then, or, once in, until INBOUND_WINDOW after its time. Without
445
+ after then, or, once in, until INBOUND_WINDOW after its journey's time
446
+ at the first stop. Without
441
447
  either, the timetabled time is shown as UNKNOWN until a minute after it.
442
448
  """
443
449
  if now.tzinfo is None:
@@ -469,19 +475,24 @@ def live_board(
469
475
  if journey.inbound_only or not heading_to(journey.destination, directions):
470
476
  continue # inbound-only journeys are there to find buses coming in, never as rows
471
477
  progress, vehicle = live.get((day, id(journey)), (None, None))
478
+ starts = midnight + timedelta(minutes=journey.origin.minute)
479
+ inbound = None
480
+ if progress is None and journey.origin.atco in labels:
481
+ inbound = follow.bus_in(journey, day)
482
+ if inbound is not None and inbound.is_in and local_now > starts + INBOUND_WINDOW:
483
+ inbound = None # still in long after its time: laid over or out of service
472
484
  for k, call in enumerate(journey.calls[:-1]): # the last call is where it terminates
473
485
  leaves = midnight + timedelta(minutes=call.minute)
474
486
  if progress is not None and progress.at > k + PASSED_MARGIN:
475
487
  continue # the bus has been past this stop
476
- inbound = follow.bus_in(journey, day) if k == 0 and progress is None else None
477
- if inbound is not None and inbound.is_in and local_now > leaves + INBOUND_WINDOW:
478
- inbound = None # still in long after its time: laid over or out of service
479
- if progress is None and _expected(leaves, None, inbound, local_now) < local_now - GRACE:
488
+ if progress is None and _expected(leaves, None, inbound, local_now, starts) < local_now - GRACE:
480
489
  continue
481
490
  if leaves > local_now + HORIZON:
482
491
  continue
483
492
  for label in labels.get(call.atco, ()):
484
- found.append(_departure(journey, day, k, leaves, progress, vehicle, label, inbound, local_now))
493
+ found.append(
494
+ _departure(journey, day, k, leaves, progress, vehicle, label, inbound, local_now, starts)
495
+ )
485
496
  found.sort(key=lambda live: (live.expected, live.leaves, live.departure.stop, live.journey.line))
486
497
  return found[:rows], list(placed.values())
487
498
 
@@ -619,18 +630,23 @@ class _Follow:
619
630
  return bool(block) and all(other.origin.minute >= journey.origin.minute for other in block)
620
631
 
621
632
 
622
- def _expected(leaves: datetime, placed: Progress | None, inbound: Inbound | None, now: datetime) -> datetime:
633
+ def _expected(
634
+ leaves: datetime, placed: Progress | None, inbound: Inbound | None, now: datetime, starts: datetime
635
+ ) -> datetime:
623
636
  """When a departure is expected: as late as its bus is, or, followed in,
624
637
  TURNAROUND after its bus gets in; never before its time. A bus already
625
638
  in is no later, however long it has waited: it leaves on time, or, that
626
- gone, any minute `now` (board-local)."""
639
+ gone, any minute `now` (board-local). `starts` is when the journey
640
+ leaves its first stop: a bus followed in is expected at a later stop the
641
+ timetable's run time from there after it is expected to leave."""
627
642
  if placed is not None:
628
643
  return leaves + timedelta(minutes=_late_minutes(placed.delay))
629
644
  if inbound is None:
630
645
  return leaves
646
+ run = leaves - starts
631
647
  if inbound.is_in:
632
- return max(leaves, now.replace(second=0, microsecond=0))
633
- return max(leaves, inbound.arrives + TURNAROUND)
648
+ return max(starts, now.replace(second=0, microsecond=0)) + run
649
+ return max(starts, inbound.arrives + TURNAROUND) + run
634
650
 
635
651
 
636
652
  def _departure(
@@ -643,10 +659,11 @@ def _departure(
643
659
  label: str,
644
660
  inbound: Inbound | None,
645
661
  now: datetime,
662
+ starts: datetime,
646
663
  ) -> LiveDeparture:
647
664
  """A board row for the k-th call of a journey, and what it came from, at
648
- `now` (board-local)."""
649
- expected = _expected(leaves, placed, inbound, now)
665
+ `now` (board-local); `starts` is when the journey leaves its first stop."""
666
+ expected = _expected(leaves, placed, inbound, now, starts)
650
667
  if placed is None and inbound is None:
651
668
  status = Status.UNKNOWN
652
669
  else:
@@ -707,14 +724,27 @@ def _along(picked: list[int], at: float) -> float | None:
707
724
  return len(picked) - 1 + (at - picked[-1])
708
725
 
709
726
 
710
- def inbound_words(inbound: Inbound, now: datetime, short: bool = False) -> str:
711
- """A bus followed in, in words: "Bus on its way, due in 6 min" at the end
712
- of the journey before, then "Bus in, waiting to leave"; `short` for a
713
- board's row, which has room for eighteen letters: "On its way, 6 min".
714
- `now` is board-local without a zone, as the departure's times are."""
715
- if inbound.is_in:
727
+ def inbound_words(live: LiveDeparture, now: datetime, short: bool = False) -> str:
728
+ """The bus followed in for a departure, in words, "due" counting down to
729
+ it getting to your stop. At the stop its journey starts: "Bus on its
730
+ way, due in 6 min" at the end of the journey before, then "Bus in,
731
+ waiting to leave". At a later stop: "Bus on its way, due in 9 min", when
732
+ the departure is expected there, then, in at the first stop, "Bus
733
+ waiting to start, due in 4 min". `short` for a board's row, which has
734
+ room for eighteen letters: "On its way, 6 min", "Bus in, waiting",
735
+ "Waiting to start". `now` is board-local without a zone, as the
736
+ departure's times are."""
737
+ inbound = live.inbound
738
+ if inbound is None:
739
+ return "No live position"
740
+ first = live.call_index == 0
741
+ if inbound.is_in and first:
716
742
  return "Bus in, waiting" if short else "Bus in, waiting to leave"
717
- minutes = int((inbound.arrives - now).total_seconds() // 60)
743
+ minutes = int(((inbound.arrives if first else live.expected) - now).total_seconds() // 60)
744
+ if inbound.is_in:
745
+ if short:
746
+ return "Waiting to start"
747
+ return f"Bus waiting to start, due in {minutes} min" if minutes >= 1 else "Bus waiting to start, due now"
718
748
  if short:
719
749
  return f"On its way, {minutes} min" if minutes >= 1 else "On its way, due"
720
750
  return f"Bus on its way, due in {minutes} min" if minutes >= 1 else "Bus on its way, due now"
@@ -726,9 +756,7 @@ def where_words(live: LiveDeparture, found: Approach | None, now: datetime) -> s
726
756
  in is (inbound_words). `found` is its approach; `now` is board-local
727
757
  without a zone."""
728
758
  if live.progress is None:
729
- if live.inbound is not None:
730
- return inbound_words(live.inbound, now)
731
- return "No live position"
759
+ return inbound_words(live, now)
732
760
  if found is None:
733
761
  return "Live position known"
734
762
  names = tuple(stop.name for stop in found.stops)
@@ -745,11 +773,10 @@ def row_strip(live: LiveDeparture, positions: dict[str, StopPosition], now: date
745
773
  if not live.live or found is None:
746
774
  return None
747
775
  if live.progress is None:
748
- inbound = live.inbound
749
- if inbound is None:
776
+ if live.inbound is None:
750
777
  return None
751
778
  try:
752
- return Strip(inbound_words(inbound, now, short=True), len(found.stops), found.yours, None)
779
+ return Strip(inbound_words(live, now, short=True), len(found.stops), found.yours, None)
753
780
  except ValueError:
754
781
  return None
755
782
  last = len(found.stops) - 1