cd67368bb75f8b174b17649c3df37bb75a75bc3b,homeassistant/components/sensor/gtfs.py,,setup_platform,#Any#Any#Any#Any#,134

Before Change



def setup_platform(hass, config, add_devices, discovery_info=None):
    Get the GTFS sensor.
    if config.get("origin") is None:
        _LOGGER.error("Origin must be set in the GTFS configuration!")
        return False

    if config.get("destination") is None:
        _LOGGER.error("Destination must be set in the GTFS configuration!")
        return False

    if config.get("data") is None:
        _LOGGER.error("Data must be set in the GTFS configuration!")
        return False

    gtfs_dir = hass.config.path("gtfs")

    if not os.path.exists(gtfs_dir):
        os.makedirs(gtfs_dir)

    if not os.path.exists(os.path.join(gtfs_dir, config["data"])):
        _LOGGER.error("The given GTFS data file/folder was not found!")
        return False

    import pygtfs

    split_file_name = os.path.splitext(config["data"])

    sqlite_file = "{}.sqlite".format(split_file_name[0])
    joined_path = os.path.join(gtfs_dir, sqlite_file)
    gtfs = pygtfs.Schedule(joined_path)

    // pylint: disable=no-member
    if len(gtfs.feeds) < 1:
        pygtfs.append_feed(gtfs, os.path.join(gtfs_dir,
                                              config["data"]))

    dev = []
    dev.append(GTFSDepartureSensor(gtfs, config["origin"],
                                   config["destination"]))
    add_devices(dev)

// pylint: disable=too-many-instance-attributes,too-few-public-methods

After Change


    if len(gtfs.feeds) < 1:
        pygtfs.append_feed(gtfs, os.path.join(gtfs_dir, data))

    add_devices([GTFSDepartureSensor(gtfs, name, origin, destination)])


// pylint: disable=too-many-instance-attributes,too-few-public-methods
class GTFSDepartureSensor(Entity):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 8

Instances


Project Name: home-assistant/home-assistant
Commit Name: cd67368bb75f8b174b17649c3df37bb75a75bc3b
Time: 2016-09-04
Author: mail@fabian-affolter.ch
File Name: homeassistant/components/sensor/gtfs.py
Class Name:
Method Name: setup_platform


Project Name: home-assistant/home-assistant
Commit Name: cce3e284d735ad2b4c71c4100bf7ce924cbf0c7f
Time: 2016-09-11
Author: mail@fabian-affolter.ch
File Name: homeassistant/components/sensor/neurio_energy.py
Class Name:
Method Name: setup_platform


Project Name: home-assistant/home-assistant
Commit Name: 8dd7ebb08e77e035127a617c9bfbd6d5a6bb6380
Time: 2016-06-29
Author: mail@fabian-affolter.ch
File Name: homeassistant/components/sensor/deutsche_bahn.py
Class Name:
Method Name: setup_platform


Project Name: home-assistant/home-assistant
Commit Name: e5ef548f1072d72a6be6df53322b3f4b8692dbc8
Time: 2016-09-02
Author: mail@fabian-affolter.ch
File Name: homeassistant/components/switch/acer_projector.py
Class Name:
Method Name: setup_platform