{ "info": { "author": "Dinu Gherman", "author_email": "gherman@darwin.in-berlin.de", "bugtrack_url": null, "classifiers": [ "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License (GPL)", "Programming Language :: Python :: 2.7" ], "description": "README\n======\n\nThis little tool will fetch and display real-time departure times for VBB/BVG \npublic transport lines for a single stop in Berlin and Brandenburg, Germany.\nHere, VBB_ is the \"Verkehrsverbund Berlin-Brandenburg\" and BVG_ is the \"Berliner\nVerkehrsbetriebe\".\n\n.. _VBB: http://www.vbb.de/en/index.html\n.. _BVG: http://www.bvg.de/en/\n\nThis tool was partly developed as an instructive example (although a toy one)\nof using Pandas_ and producing some output to be fed into a web-based \ndashboard like those one can create with Dashing_ (to be done). \n\n.. _Pandas: http://pandas.pydata.org\n.. _Dashing: http://dashing.io\n\n\n\nSample output\n-------------\n\nHere is an example output for \"M\u00f6ckernbr\u00fccke\" (including the optional ``--header``)\non the command-line:\n\n.. code-block:: console\n\n $ vbbvg --stop M\u00f6ckernbr\u00fccke --header\n Now: 14:06:04\n Stop-Name: U M\u00f6ckernbr\u00fccke (Berlin)\n Stop-ID: 9017104\n\n Wait Departure Line Destination\n ------ ----------- ------ ----------------------------\n 00:48 14:07 U1 U Uhlandstr. (Berlin)\n 02:48 14:09 U7 S+U Rathaus Spandau (Berlin)\n 02:48 14:09 U1 S+U Warschauer Str. (Berlin)\n 04:48 14:11 U7 U Rudow (Berlin)\n\nThis shows the waiting and departure times (in MM:SS and HH:MM format,\nrespectively) from one stop, limited to all earliest unique combinations of\nthe *Line* and *Destination* columns.\nThis is usually the only information one is interested in just \"before\nleaving the office\" as a typical use-case.\nThis tool filters these combinations, calculates the waiting times and inserts\nthem as the first column in the output.\nThere are quite a few other command-line options which you can find out more\nabout by typing ``python vbbvg -h``.\n\n\nInstallation and Test\n---------------------\n\nYou can clone the repository and install it via pip. After\ninstalling, you will have access system wide (or in your virtualenv)\nto ``vbbvg`` programmatically or via the CLI.\n\n::\n\n pip install -e .\n\nThere is a list of dependencies in the file ``requirements.txt``\n(for more about them please read the next section) which you can install\nwith the command ``pip install -r requirements.txt``. \n\nTo run the little \"test suite\", download and unpack this repository or\nclone it, and run the command ``python setup.py test`` in the unpacked archive. \nOf course this needs the ``pytest`` package to be available (not listed in \nthe requirements, but easy to install with ``pip install pytest``).\n\n\nDependencies\n------------\n\nThis tool was partly developed as an instructive example of using Pandas_ for \ngreatly simplifying the code needed for working with tables (``DataFrame``\nobjects).\nThe ``BeautifulSoup4`` and ``html5lib`` packages are optional dependencies,\nbut needed for ``pandas.read_html()`` which will barf if they are not\ninstalled.\nOutput on the command-line is created by using the ``termcolor`` and \n``tabulate`` packages, saving a great amount of code to write otherwise\noneself.\n\nSystem Requirements (Linux)\n...........................\n\nAs a Linux user pointed out: if you are on Linux you might have to install\nthe following packages manually:\n\n.. code-block:: console\n\n sudo apt-get install libxml2-dev libxslt1-dev\n\nAnd if you run into an ``/usr/bin/ld: cannot find -lz`` error consider \ninstalling this one before running ``pip``, too:\n\n.. code-block:: console\n\n sudo apt-get install lib32z1-dev\n\n\nImplementation\n--------------\n\nSince VBB/BVG have no API for real time data access this data is fetched \n(scraped using Pandas_, yes!) from a web application on http://mobil.bvg.de.\nYou can use this page for `testing manually`_ (in English).\nThere, as a real person, you can enter parts of the destination name and get\na list of matching destinations to chose from, before you get to see the one\nresult table you are interested in.\n\n.. _testing manually:\n http://mobil.bvg.de/Fahrinfo/bin/stboard.bin/eox?&boardType=depRT\n\nTo avoid multi-level scraping, speed things up, and add some more thrills, \na small part of an existing \"Open Data\" `VBB database`_, published under the \n`CC-BY 3.0 license `_ \nis used to access the stop names and IDs of the VBB/BVG public transport \nnetwork (a simple CSV file named here ``vbbvg_stops.csv``).\n\n.. _VBB database: http://daten.berlin.de/kategorie/verkehr\n\nThe resulting tables are output as \"real\" tables in various formats on\nthe command-line, see usage examples below.\n\n\nUsage\n-----\n\nCommand-Line\n............\n\nYou can run a few sample command-line calls using the options ``--test`` \nand ``--stop `` for a given stop name or ID like this for the \nstop *M\u00f6ckernbr\u00fccke*:\n\n.. code-block:: console\n\n $ vbbvg --test --stop M\u00f6ckernbr\u00fccke\n\n\nProgrammatic\n............\n\nThe main function to use programmatically is ``vbbvg.get_next_departures()``,\nwhich returns a Pandas_ ``DataFrame`` object, which you can convert to almost\nanything you like. See the following examples:\n\nGet departures of S7 and S75 from Berlin main station:\n\n.. code-block:: python\n\n In [1]: import vbbvg\n \n In [2]: df = vbbvg.get_next_departures('9003201', filter_line='S7')\n \n In [3]: df.columns\n Out[3]: Index([u'Wait', u'Departure', u'Line', u'Destination'], dtype='object')\n\n In [4]: list(df.to_records())\n Out[4]: \n [(1, '00:00', u'10:01', u'S75 (Gl. 16)', u'S Westkreuz (Berlin)'),\n (4, '01:10', u'10:03', u'S75 (Gl. 15)', u'S Wartenberg (Berlin)'),\n (14, '04:10', u'10:06', u'S7 (Gl. 16)', u'S Potsdam Hauptbahnhof'),\n (24, '07:10', u'10:09', u'S7 (Gl. 15)', u'S Ahrensfelde Bhf (Berlin)'),\n (62, '21:10', u'10:23', u'S75 (Gl. 15)', u'S Ostbahnhof (Berlin)')]\n \n In [5]: print(df.to_csv())\n ,Wait,Departure,Line,Destination\n 1,00:00,10:01,S75 (Gl. 16),S Westkreuz (Berlin)\n 4,01:10,10:03,S75 (Gl. 15),S Wartenberg (Berlin)\n 14,04:10,10:06,S7 (Gl. 16),S Potsdam Hauptbahnhof\n 24,07:10,10:09,S7 (Gl. 15),S Ahrensfelde Bhf (Berlin)\n 62,21:10,10:23,S75 (Gl. 15),S Ostbahnhof (Berlin)\n \n\nDashboards\n..........\n\nWhen using this tool inside some kind of web-based dashboard like those \ncreated by Dashing_ (which was the originally intended use-case) \none should use a stop's ID to be sure to provide a unique stop on the \nVBB/BVG public transport network. You can find out the IDs by running \ntest queries with the ``--header`` option.\n\n\nTodo\n----\n\n- mention http://fahrinfo.vbb.de/bin/stboard.exe/en? (provides some more \n filtering features)\n- add more examples in the Usage section above\n- make the code *polyglot*, running not only on Python 2.7 but also 3.4/3.5\n- test option to filter specific line types like S-Bahn ('S.*') or single \n lines ('U7')\n- use in some real dashboard like those of dhasing.io (the original purpose!)\n- mention that case is ignored in the whole tool for all stop names\n- store the last displayed stop (in ~/.vvbvg or so) and reuse when called\n without any args/options\n- remove index numbers (leftmost column) from result tables when used\n programmatically\n\nDue to time limitations any help is welcome with any of the items above.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/deeplook/vbbvg", "keywords": "real-time,transport-data", "license": "GPL", "maintainer": null, "maintainer_email": null, "name": "vbbvg", "package_url": "https://pypi.org/project/vbbvg/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/vbbvg/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/deeplook/vbbvg" }, "release_url": "https://pypi.org/project/vbbvg/0.0.1/", "requires_dist": null, "requires_python": null, "summary": "Fetch and display real-time departure times for VBB/BVG public transport", "version": "0.0.1" }, "last_serial": 2121329, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "b2c25fa4086ffeddc1dc3b139d58406f", "sha256": "6979544724071b30fa6b13b1ab712054b612a8a461df01101ea7ddde362bc788" }, "downloads": -1, "filename": "vbbvg-0.0.1.tar.gz", "has_sig": false, "md5_digest": "b2c25fa4086ffeddc1dc3b139d58406f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 274088, "upload_time": "2016-05-18T08:15:55", "url": "https://files.pythonhosted.org/packages/10/17/70700121fa25791a7582197567539ea10e59963e4f8ba15adc0e55b9639d/vbbvg-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b2c25fa4086ffeddc1dc3b139d58406f", "sha256": "6979544724071b30fa6b13b1ab712054b612a8a461df01101ea7ddde362bc788" }, "downloads": -1, "filename": "vbbvg-0.0.1.tar.gz", "has_sig": false, "md5_digest": "b2c25fa4086ffeddc1dc3b139d58406f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 274088, "upload_time": "2016-05-18T08:15:55", "url": "https://files.pythonhosted.org/packages/10/17/70700121fa25791a7582197567539ea10e59963e4f8ba15adc0e55b9639d/vbbvg-0.0.1.tar.gz" } ] }