Esempio n. 1
0
    def test_train_routes_accessor(self):
        train_route_accessor.reset()
        train_route = TrainRoute()
        train_route.line_name = 'Den-en-Toshi'
        train_route.stations = ['Shibuya', 'Aobadai', 'Eda']

        train_route_accessor.upset_train_route(train_route)
        post_train_route = train_route_accessor.get_train_route_by_line('Den-en-Toshi')
        self.assertEqual(post_train_route.line_name, train_route.line_name)
        self.assertSequenceEqual(post_train_route.stations, train_route.stations)
Esempio n. 2
0
def get_train_routes():
    """
    :rtype :list[TrainRoute]
    :return:
    """
    train_routes_list = []
    train_scrapper = scrap(
        'https://en.wikipedia.org/w/index.php?title=KA_Commuter_Jabodetabek&oldid=683328854')
    raw_tables = train_scrapper.select('dl > dd > b')
    for table in raw_tables:
        line_name = \
            re.findall('[a-zA-Z0-9 ]+[a-zA-Z0-9]', table.parent.parent.previousSibling.previousSibling.string)[
                0].strip()
        station_list = LinkedHash(
            map(lambda x: 'Stasiun ' + x.strip(),
                re.sub(u'\u2192', ',', re.sub('\\.', '', table.parent.getText())).split(',')))
        train_route = TrainRoute()
        train_route.line_name = line_name
        train_route.stations = station_list
        train_routes_list.append(train_route)
    return train_routes_list
Esempio n. 3
0
def get_train_routes():
    """
    :rtype :list[TrainRoute]
    :return:
    """
    train_routes_list = []
    train_scrapper = scrap(
        'https://en.wikipedia.org/w/index.php?title=KA_Commuter_Jabodetabek&oldid=683328854'
    )
    raw_tables = train_scrapper.select('dl > dd > b')
    for table in raw_tables:
        line_name = \
            re.findall('[a-zA-Z0-9 ]+[a-zA-Z0-9]', table.parent.parent.previousSibling.previousSibling.string)[
                0].strip()
        station_list = LinkedHash(
            map(
                lambda x: 'Stasiun ' + x.strip(),
                re.sub(u'\u2192', ',',
                       re.sub('\\.', '', table.parent.getText())).split(',')))
        train_route = TrainRoute()
        train_route.line_name = line_name
        train_route.stations = station_list
        train_routes_list.append(train_route)
    return train_routes_list
 def to_train_route(self):
     train_route = TrainRoute()
     train_route.line_name = self.line_name
     train_route.stations = self.stations.split(';')
     return train_route
Esempio n. 5
0
 def to_train_route(self):
     train_route = TrainRoute()
     train_route.line_name = self.line_name
     train_route.stations = self.stations.split(';')
     return train_route