summaryrefslogtreecommitdiff
path: root/lib/DBInfoscreen.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/DBInfoscreen.pm')
-rw-r--r--lib/DBInfoscreen.pm30
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/DBInfoscreen.pm b/lib/DBInfoscreen.pm
index 3a429e7..acb741b 100644
--- a/lib/DBInfoscreen.pm
+++ b/lib/DBInfoscreen.pm
@@ -101,25 +101,31 @@ sub startup {
$self->attr(
ice_type_map => sub {
- my $ice_type_map = JSON->new->utf8->decode(
- scalar read_file('share/zugbildungsplan.json') );
- my $ret;
- while ( my ( $k, $v ) = each %{ $ice_type_map->{train} } ) {
- if ( $v->{type} ) {
- $ret->{$k} = [
- $v->{type}, $v->{shortType},
- exists $v->{wagons} ? 1 : 0
- ];
+ if ( -r 'share/zugbildungsplan.json' ) {
+ my $ice_type_map = JSON->new->utf8->decode(
+ scalar read_file('share/zugbildungsplan.json') );
+ my $ret;
+ while ( my ( $k, $v ) = each %{ $ice_type_map->{train} } ) {
+ if ( $v->{type} ) {
+ $ret->{$k} = [
+ $v->{type}, $v->{shortType},
+ exists $v->{wagons} ? 1 : 0
+ ];
+ }
}
+ return $ret;
}
- return $ret;
+ return {};
}
);
$self->attr(
train_details_db => sub {
- return JSON->new->utf8->decode(
- scalar read_file('share/zugbildungsplan.json') )->{train};
+ if ( -r 'share/zugbildungsplan.json' ) {
+ return JSON->new->utf8->decode(
+ scalar read_file('share/zugbildungsplan.json') )->{train};
+ }
+ return {};
}
);