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

Before Change


        _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


    gtfs_dir = hass.config.path(DEFAULT_PATH)
    data = config.get(CONF_DATA)
    origin = config.get(CONF_ORIGIN)
    destination = config.get(CONF_DESTINATION)
    name = config.get(CONF_NAME)

    if not os.path.exists(gtfs_dir):
        os.makedirs(gtfs_dir)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

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: 09d531b3b95e7943df53233d1abcb40d7e87de94
Time: 2016-08-18
Author: nkgilley@gmail.com
File Name: homeassistant/components/media_player/gpmdp.py
Class Name:
Method Name: setup_platform