summaryrefslogtreecommitdiff
path: root/bin/efa
diff options
context:
space:
mode:
Diffstat (limited to 'bin/efa')
-rwxr-xr-xbin/efa100
1 files changed, 38 insertions, 62 deletions
diff --git a/bin/efa b/bin/efa
index 466ea61..4449970 100755
--- a/bin/efa
+++ b/bin/efa
@@ -43,6 +43,42 @@ sub show_help {
exit $exit_status;
}
+sub new_efa_by_url {
+ my ($url) = @_;
+ my $res = eval {
+ Travel::Routing::DE::EFA->new(
+ efa_url => $url,
+
+ origin => [ @from, $from_type ],
+ destination => [ @to, $to_type ],
+ via => ( @via ? [ @via, $via_type ] : undef ),
+
+ arrival_time => $opt->{arrive},
+ departure_time => $opt->{depart},
+ date => $opt->{date},
+ exclude => $opt->{exclude},
+ train_type => $opt->{include},
+ with_bike => $opt->{bike},
+
+ select_interchange_by => $opt->{prefer},
+ use_near_stops => $opt->{proximity},
+ walk_speed => $opt->{'walk-speed'},
+ max_interchanges => $opt->{'max-change'},
+ num_results => $opt->{'num-connections'},
+
+ without_solid_stairs => $opt->{without_solid_stairs},
+ without_escalators => $opt->{without_escalators},
+ without_elevators => $opt->{without_elevators},
+ with_low_platform => $opt->{with_low_platform},
+ with_wheelchair => $opt->{with_wheelchair},
+
+ developer_mode => $opt->{devmode},
+ lwp_options => { timeout => $opt->{timeout} },
+ );
+ };
+ return $res;
+}
+
sub handle_efa_exception {
my ($e) = @_;
@@ -375,37 +411,7 @@ if ( $opt->{service} ) {
if ( $opt->{discover} or $opt->{'auto-url'} ) {
for my $service ( Travel::Routing::DE::EFA::get_efa_urls() ) {
- $efa = eval {
- Travel::Routing::DE::EFA->new(
- efa_url => $service->{url},
-
- origin => [ @from, $from_type ],
- destination => [ @to, $to_type ],
- via => ( @via ? [ @via, $via_type ] : undef ),
-
- arrival_time => $opt->{arrive},
- departure_time => $opt->{depart},
- date => $opt->{date},
- exclude => $opt->{exclude},
- train_type => $opt->{include},
- with_bike => $opt->{bike},
-
- select_interchange_by => $opt->{prefer},
- use_near_stops => $opt->{proximity},
- walk_speed => $opt->{'walk-speed'},
- max_interchanges => $opt->{'max-change'},
- num_results => $opt->{'num-connections'},
-
- without_solid_stairs => $opt->{without_solid_stairs},
- without_escalators => $opt->{without_escalators},
- without_elevators => $opt->{without_elevators},
- with_low_platform => $opt->{with_low_platform},
- with_wheelchair => $opt->{with_wheelchair},
-
- developer_mode => $opt->{devmode},
- lwp_options => { timeout => $opt->{timeout} },
- );
- };
+ $efa = new_efa_by_url( $service->{url} );
if ($efa) {
if ( $opt->{'auto-url'} ) {
last;
@@ -422,37 +428,7 @@ if ( $opt->{discover} or $opt->{'auto-url'} ) {
}
}
else {
- $efa = eval {
- Travel::Routing::DE::EFA->new(
- efa_url => $efa_url,
-
- origin => [ @from, $from_type ],
- destination => [ @to, $to_type ],
- via => ( @via ? [ @via, $via_type ] : undef ),
-
- arrival_time => $opt->{arrive},
- departure_time => $opt->{depart},
- date => $opt->{date},
- exclude => $opt->{exclude},
- train_type => $opt->{include},
- with_bike => $opt->{bike},
-
- select_interchange_by => $opt->{prefer},
- use_near_stops => $opt->{proximity},
- walk_speed => $opt->{'walk-speed'},
- max_interchanges => $opt->{'max-change'},
- num_results => $opt->{'num-connections'},
-
- without_solid_stairs => $opt->{without_solid_stairs},
- without_escalators => $opt->{without_escalators},
- without_elevators => $opt->{without_elevators},
- with_low_platform => $opt->{with_low_platform},
- with_wheelchair => $opt->{with_wheelchair},
-
- developer_mode => $opt->{devmode},
- lwp_options => { timeout => $opt->{timeout} },
- );
- };
+ $efa = new_efa_by_url($efa_url);
}
check_for_error($@);