实时BART(湾区快速交通)信息在您的终端!

pybart的Python项目详细描述


VersionPython versionsWheel statusLicense

实时BART(Bay Area Rapid Transit)信息 在你的终端!

Screenshot

功能

  • 实时评估和服务咨询
  • Curses-based 自动刷新和调整大小的TUI
  • 同时查看多个电台
  • 表示公交线路、估计时间和列车长度的颜色
  • 能够配置一组默认电台
  • 其他非TUI命令,如打开地图并获取旅行费用
  • 包括用于完整BART API的低级Python包装器
  • 无依赖项;仅使用标准库构建

要求

  • python 2.6+或python 3.0+,安装了curses模块(即 车窗)
  • 支持256色的终端,以正确显示里士满弗里蒙特 线为橙色(否则为洋红色)
    • 注意:这通常涉及将TERM环境变量设置为 xterm-256color

安装

pip install pybart

用法

usage: bart [-h] [-v] {map,list,est,fare} ...

Display real time BART estimates.

optional arguments:
  -h, --help           show this help message and exit
  -v, --version        show program's version number and exit

commands:
  {map,list,est,fare}
    map                open station map in web browser
    list               show list of stations and their abbreviations
    est                display estimates for specified stations
    fare               show fare for a trip between two stations

examples:
  bart                 get estimates for $BART_STATIONS
  bart map             open station map
  bart list            list all stations
  bart est mcar        get estimates for MacArthur station
  bart est embr cols   get estimates for Embarcadero and Coliseum stations
  bart fare conc sfia  get fare for a trip between Concord and SFO stations

配置

以下(可选)环境变量可用于配置Pybart:

  • BART_STATIONS-逗号分隔的字符串(例如mcar,embr,cols) 指定运行bart时要使用的默认工作站 论据。
  • BART_API_KEY-获取信息时要使用的BART API密钥。一个 默认情况下使用public one,但您可以获得自己的 here

API

尽管pybart并没有全部使用,但它包含了一个低级python 全套包装 BART APIpybart.api.BART。默认情况下,每个调用都返回XML的根元素 使用响应 ElementTree。 json也受支持,但格式当前为 beta

示例用法:

>>> from pybart.api import BART
>>> bart = BART()  # Uses the public API key by default
>>> root = bart.stn.stninfo('dbrk')
>>> station = root.find('stations').find('station')
>>> print(station.find('address').text + ', ' + station.find('city').text)
2160 Shattuck Avenue, Berkeley
>>> print(bart.version().find('apiVersion').text)
3.10
>>> bart = BART(json_format=True)  # Now with JSON
>>> root = bart.stn.stninfo('dbrk')
>>> station = root['stations']['station']
>>> print(station['address'] + ', ' + station['city'])
2160 Shattuck Avenue, Berkeley

许可证

BSD 3-Clause

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何在Java中创建固定大小的泛型数组?   javascript Paypal Braintree订阅付款   使用BufferedReader和PrintWriter实现java数据持久化?   类似于iCloud的java唯一google id   java使用网格布局和抓取组合框   java我的while循环无限运行,当我检查它时,它说while循环没有主体,而我认为它显然没有主体   java LWJGL碰撞3D OpenGL   java将Tibco RV切换到WebSphere MQ?   java如何使用Postman从curl发布REST   java是超级的,在通用通配符中是独占的吗?   在swing 1.5中,java在指定时间后自动关闭非模态对话框   java PrimeFaces饼图在JSF 2.0中不显示   java如何在Spring MVC中提供带有xml配置的默认bean实现?   java在eclipse中使用按钮关闭JFrame   java Sqoop jar已弃用   Java中的Getter方法