Skip to content
GitLab
Explore
Sign in
derf
Travel-Routing-DE-EFA
Compare revisions
6c191741e82aa908ef59f1059c72bf33d0577de1 to c2bca25311120762451d5c2b169bef32bffb31ae
Commits on Source (2)
add mailmap
· 92be99d7
Birte Kristina Friesel
authored
Nov 22, 2023
92be99d7
efa: Less dense output; show important parts first
· c2bca253
Birte Kristina Friesel
authored
Nov 22, 2023
Also: now shows departure and arrival delay separately
c2bca253
Hide whitespace changes
Inline
Side-by-side
.mailmap
0 → 100644
View file @
c2bca253
Birte Kristina Friesel <derf@chaosdorf.de>
Birte Kristina Friesel <derf@finalrewind.org>
Birte Kristina Friesel <derf@derf.homelinux.org>
bin/efa
View file @
c2bca253
...
@@ -10,7 +10,7 @@ use Encode qw(decode);
...
@@ -10,7 +10,7 @@ use Encode qw(decode);
use
Travel::Routing::DE::
EFA
;
use
Travel::Routing::DE::
EFA
;
use
Exception::
Class
;
use
Exception::
Class
;
use
Getopt::
Long
qw/:config no_ignore_case/
;
use
Getopt::
Long
qw/:config no_ignore_case/
;
use
List::
Util
qw(first)
;
use
List::
Util
qw(first
max
)
;
our
$VERSION
=
'
2.23
';
our
$VERSION
=
'
2.23
';
my
$ignore_info
;
my
$ignore_info
;
...
@@ -30,6 +30,9 @@ my $opt = {
...
@@ -30,6 +30,9 @@ my $opt = {
binmode
(
STDOUT
,
'
:encoding(utf-8)
'
);
binmode
(
STDOUT
,
'
:encoding(utf-8)
'
);
binmode
(
STDERR
,
'
:encoding(utf-8)
'
);
binmode
(
STDERR
,
'
:encoding(utf-8)
'
);
my
$output_bold
=
-
t
STDOUT
?
"
\033
[1m
"
:
q{}
;
my
$output_reset
=
-
t
STDOUT
?
"
\033
[0m
"
:
q{}
;
sub
show_help
{
sub
show_help
{
my
(
$exit_status
)
=
@_
;
my
(
$exit_status
)
=
@_
;
...
@@ -170,6 +173,14 @@ sub format_footpath {
...
@@ -170,6 +173,14 @@ sub format_footpath {
return
$str
;
return
$str
;
}
}
sub
format_delay
{
my
(
$delay
,
$len
)
=
@_
;
if
(
$delay
and
$len
)
{
return
sprintf
(
"
(%+
${len}
d)
",
$delay
);
}
return
q{}
;
}
sub
display_routes
{
sub
display_routes
{
my
(
@routes
)
=
@_
;
my
(
@routes
)
=
@_
;
...
@@ -189,8 +200,19 @@ sub display_routes {
...
@@ -189,8 +200,19 @@ sub display_routes {
}
}
}
}
my
$delay_len
=
0
;
for
my
$c
(
$route
->
parts
)
{
for
my
$c
(
$route
->
parts
)
{
display_connection
(
$c
);
if
(
$c
->
departure_delay
)
{
$delay_len
=
max
(
$delay_len
,
length
(
$c
->
departure_delay
)
+
1
);
}
if
(
$c
->
arrival_delay
)
{
$delay_len
=
max
(
$delay_len
,
length
(
$c
->
arrival_delay
)
+
1
);
}
}
for
my
$c
(
$route
->
parts
)
{
display_connection
(
$c
,
$delay_len
);
}
}
# last one needs to be shown separately
# last one needs to be shown separately
...
@@ -209,22 +231,13 @@ sub display_routes {
...
@@ -209,22 +231,13 @@ sub display_routes {
}
}
sub
display_connection
{
sub
display_connection
{
my
(
$c
)
=
@_
;
my
(
$c
,
$delay_len
)
=
@_
;
my
$delay_fmt
=
$delay_len
?
$delay_len
+
2
:
0
;
if
(
$c
->
is_cancelled
)
{
if
(
$c
->
is_cancelled
)
{
say
'
# FAHRT FÄLLT AUS
';
say
'
# FAHRT FÄLLT AUS
';
}
}
elsif
(
$c
->
delay
)
{
printf
(
"
# +%d, Plan: %s -> %s
\n
",
$c
->
delay
,
$c
->
departure_stime
,
$c
->
arrival_stime
);
}
for
my
$note
(
$c
->
regular_notes
)
{
my
$text
=
$note
->
summary
;
if
(
not
(
length
$ignore_info
and
$text
=~
/$ignore_info/i
)
)
{
say
"
#
$text
";
}
}
my
$occupancy
=
q{}
;
my
$occupancy
=
q{}
;
...
@@ -240,15 +253,6 @@ sub display_connection {
...
@@ -240,15 +253,6 @@ sub display_connection {
}
}
}
}
for
my
$notice
(
$c
->
current_notes
)
{
if
(
$notice
->
subtitle
ne
$notice
->
subject
)
{
printf
(
"
# %s - %s
\n
",
$notice
->
subtitle
,
$notice
->
subject
);
}
else
{
printf
(
"
# %s
\n
",
$notice
->
subtitle
);
}
}
if
(
$opt
->
{
maps
}
)
{
if
(
$opt
->
{
maps
}
)
{
for
my
$m
(
$c
->
departure_routemaps
,
$c
->
departure_stationmaps
)
{
for
my
$m
(
$c
->
departure_routemaps
,
$c
->
departure_stationmaps
)
{
say
"
#
$m
";
say
"
#
$m
";
...
@@ -256,22 +260,49 @@ sub display_connection {
...
@@ -256,22 +260,49 @@ sub display_connection {
}
}
printf
(
printf
(
"
%-5s ab %-30s %-20s %s
\n
",
"
${output_bold}
%s
${output_reset}
%s %s
\n
",
$c
->
train_line
||
$c
->
train_product
,
$c
->
train_destination
?
q{→}
:
q{ }
,
$c
->
train_destination
);
printf
(
"
%-5s %-
${delay_fmt}
s ab %-30s
\n
",
$c
->
departure_time
,
$c
->
departure_time
,
format_delay
(
$c
->
departure_delay
,
$delay_len
),
$c
->
departure_stop_and_platform
,
$c
->
departure_stop_and_platform
,
$c
->
train_line
||
$c
->
train_product
,
$c
->
train_destination
,
);
);
if
(
$opt
->
{'
full-route
'}
)
{
if
(
$opt
->
{'
full-route
'}
)
{
for
my
$via_stop
(
$c
->
via
)
{
for
my
$via_stop
(
$c
->
via
)
{
printf
(
"
%-5s %-30s %s
\n
",
printf
(
"
%-5s %-
${delay_fmt}
s %-30s %s
\n
",
$via_stop
->
[
1
],
$via_stop
->
[
2
],
$via_stop
->
[
3
]
);
$via_stop
->
[
1
],
q{}
,
$via_stop
->
[
2
],
$via_stop
->
[
3
]
);
}
}
printf
(
"
%-5s %-
${delay_fmt}
s an %-30s %s
\n
",
$c
->
arrival_time
,
format_delay
(
$c
->
arrival_delay
,
$delay_len
),
$c
->
arrival_stop_and_platform
,
$occupancy
);
for
my
$notice
(
$c
->
current_notes
)
{
if
(
$notice
->
subtitle
ne
$notice
->
subject
)
{
printf
(
"
# %s - %s
\n
",
$notice
->
subtitle
,
$notice
->
subject
);
}
else
{
printf
(
"
# %s
\n
",
$notice
->
subtitle
);
}
}
for
my
$note
(
$c
->
regular_notes
)
{
my
$text
=
$note
->
summary
;
if
(
not
(
length
$ignore_info
and
$text
=~
/$ignore_info/i
)
)
{
say
"
#
$text
";
}
}
}
}
printf
(
"
%-5s an %-30s %s
\n
",
$c
->
arrival_time
,
$c
->
arrival_stop_and_platform
,
$occupancy
);
print
"
\n
";
print
"
\n
";
if
(
$opt
->
{'
extended-info
'}
if
(
$opt
->
{'
extended-info
'}
...
...