1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use Cache::File;
use List::Util qw(uniq);
use Travel::Status::DE::IRIS;
use Travel::Status::DE::IRIS::Stations;
my ($station) = @ARGV;
my $cache_path = $ENV{XDG_CACHE_HOME} // "$ENV{HOME}/.cache";
my $schedule_cache_path = "${cache_path}/db-iris-schedule";
my $realtime_cache_path = "${cache_path}/db-iris-realtime";
my ( $schedule_cache, $realtime_cache );
eval {
use Cache::File;
$schedule_cache = Cache::File->new(
cache_root => $schedule_cache_path,
default_expires => '6 hours',
lock_level => Cache::File::LOCK_LOCAL(),
);
$realtime_cache = Cache::File->new(
cache_root => $realtime_cache_path,
default_expires => '180 seconds',
lock_level => Cache::File::LOCK_LOCAL(),
);
};
if ($@) {
$schedule_cache = undef;
$realtime_cache = undef;
}
my $status = Travel::Status::DE::IRIS->new(
station => $station,
main_cache => $schedule_cache,
realtime_cache => $realtime_cache,
with_related => 1,
);
my @missing;
for my $result ( $status->results ) {
if ( $result->type eq 'Bus' ) {
next;
}
for my $name ( $result->route_pre, $result->route_post ) {
my @matches
= Travel::Status::DE::IRIS::Stations::get_station_by_name($name);
if ( @matches != 1 ) {
push( @missing, $name );
}
elsif ( $matches[0][1] ne $name ) {
push( @missing, $name );
}
}
}
say join( "\n", uniq @missing );
|