<commit_before># -*- coding: utf-8 -*-

# Copyright(C) 2010-2011 <NAME>, <NAME>
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.


from datetime import time, datetime

from .base import IBaseCap, CapBaseObject


__all__ = ['Departure', 'ICapTravel', 'Station']


class Station(CapBaseObject):
    def __init__(self, id, name):
        CapBaseObject.__init__(self, id)
        self.add_field('name', basestring, name)

    def __repr__(self):
        return "<Station id=%r name=%r>" % (self.id, self.name)


class Departure(CapBaseObject):
    def __init__(self, id, _type, _time):
        CapBaseObject.__init__(self, id)

        self.add_field('type', basestring, _type)
        self.add_field('time', datetime, _time)
        self.add_field('departure_station', basestring)
        self.add_field('arrival_station', basestring)
        self.add_field('late', time, time())
        self.add_field('information', basestring)
        self.add_field('plateform', basestring)

    def __repr__(self):
        return u"<Departure id=%r type=%r time=%r departure=%r arrival=%r>" % (
            self.id, self.type, self.time.strftime('%H:%M'), self.departure_station, self.arrival_station)

class ICapTravel(IBaseCap):
    def iter_station_search(self, pattern):
        """
        Iterates on search results of stations.

        @param pattern [str]  the search pattern
        @return [iter]  the of Station objects
        """
        raise NotImplementedError()

    def iter_station_departures(self, station_id, arrival_id):
        """
        Iterate on departures.

        @param station_id [id]  the station id
        @param arrival_id [id]  optionnal arrival station id
        @return [iter]  result of Departure objects
        """
        raise NotImplementedError()<commit_msg>support roadmaps in ICapTravel (closes #680)<commit_after># -*- coding: utf-8 -*-

# Copyright(C) 2010-2011 <NAME>, <NAME>
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.


from datetime import time, datetime, timedelta

from .base import IBaseCap, CapBaseObject


__all__ = ['Departure', 'ICapTravel', 'Station']


class Station(CapBaseObject):
    def __init__(self, id, name):
        CapBaseObject.__init__(self, id)
        self.add_field('name', basestring, name)

    def __repr__(self):
        return "<Station id=%r name=%r>" % (self.id, self.name)

class Departure(CapBaseObject):
    def __init__(self, id, _type, _time):
        CapBaseObject.__init__(self, id)

        self.add_field('type', basestring, _type)
        self.add_field('time', datetime, _time)
        self.add_field('departure_station', basestring)
        self.add_field('arrival_station', basestring)
        self.add_field('late', time, time())
        self.add_field('information', basestring)
        self.add_field('plateform', basestring)

    def __repr__(self):
        return u"<Departure id=%r type=%r time=%r departure=%r arrival=%r>" % (
            self.id, self.type, self.time.strftime('%H:%M'), self.departure_station, self.arrival_station)

class RoadStep(CapBaseObject):
    def __init__(self, id):
        CapBaseObject.__init__(self, id)

        self.add_field('line', basestring)
        self.add_field('start_time', time)
        self.add_field('end_time', time)
        self.add_field('departure', unicode)
        self.add_field('arrival', unicode)
        self.add_field('duration', timedelta)

class ICapTravel(IBaseCap):
    def iter_station_search(self, pattern):
        """
        Iterates on search results of stations.

        @param pattern [str]  the search pattern
        @return [iter]  the of Station objects
        """
        raise NotImplementedError()

    def iter_station_departures(self, station_id, arrival_id):
        """
        Iterate on departures.

        @param station_id [id]  the station id
        @param arrival_id [id]  optionnal arrival station id
        @return [iter]  result of Departure objects
        """
        raise NotImplementedError()

    def iter_roadmap(self, departure, arrival):
        """
        Get a roadmap.

        @param departure [str]  name of departure station
        @param arrival [str]  name of arrival station
        @return [iter(RoadStep)]  steps of roadmap
        """
        raise NotImplementedError()
{'fraction_non_alphanumeric': 0.10495837857401376, 'fraction_numerical': 0.004162142598624683, 'mean_word_length': 3.2126524390243905, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3077423', 'n_tokens_mistral': 1675, 'n_tokens_neox': 1612, 'n_words': 528}