From: Andrew Ruthven Date: Mon, 12 Nov 2018 11:36:57 +0000 (+1300) Subject: Eradicate tabs, line things up, add missing commas at ends of hashes/arrays X-Git-Tag: 1.0.0~55 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=38431f14a5000e6653e6cb4e17bf7f3428da7f8a;p=mythtv-status.git Eradicate tabs, line things up, add missing commas at ends of hashes/arrays I've been putting this off for years, but it is finally time. --- diff --git a/bin/mythtv-status b/bin/mythtv-status index 9dd0dcd..47ae766 100755 --- a/bin/mythtv-status +++ b/bin/mythtv-status @@ -227,11 +227,11 @@ my @blocks = ( '&date' => sub { my ($value, $vars) = @_; - if (defined $vars->{ISODate} && $vars->{ISODate} =~ /Z$/) { - return process_iso_date($vars->{ISODate}); - } else { - return $vars->{date} . ", " . $vars->{time}; - } + if (defined $vars->{ISODate} && $vars->{ISODate} =~ /Z$/) { + return process_iso_date($vars->{ISODate}); + } else { + return $vars->{date} . ", " . $vars->{time}; + } }, }, }, @@ -251,7 +251,8 @@ my @blocks = ( '^1$' => "${warning}Watching LiveTV${normal}", '^2$' => "${warning}Watching Pre-recorded${normal}", '^3$' => "${warning}Watching Recording${normal}", - '^4$' => "${warning}Recording${normal}" }, + '^4$' => "${warning}Recording${normal}", + }, }, 'filter' => { 'state' => sub { return $c->{'encoder_skip_idle'} && $_[0] == 0 }, @@ -276,7 +277,8 @@ my @blocks = ( '^3$' => "${warning}Watching DVD${normal}", '^4$' => "${warning}Watching Video${normal}", '^5$' => "${warning}Watching Recording${normal}", - '^6$' => "${warning}Recording${normal}" }, + '^6$' => "${warning}Recording${normal}", + }, }, 'filter' => { 'state' => sub { return $c->{'encoder_skip_idle'} && $_[0] == 0 }, @@ -304,7 +306,8 @@ my @blocks = ( '^4$' => "${warning}Watching Blu-ray${normal}", '^5$' => "${warning}Watching Video${normal}", '^6$' => "${warning}Watching Recording${normal}", - '^7$' => "${warning}Recording${normal}" }, + '^7$' => "${warning}Recording${normal}", + }, }, 'filter' => { 'state' => sub { return $c->{'encoder_skip_idle'} && $_[0] == 0 }, @@ -324,8 +327,8 @@ my @blocks = ( 'xpath' => "//Status/Encoders/Encoder/Program", 'hide' => 'after', 'attrs' => [ qw/title endTime channelName:.\/Channel[@channelName] - encoderId:.\/Recording[@encoderId] - chanNum:.\/Channel[@chanNum]/ ], + encoderId:.\/Recording[@encoderId] + chanNum:.\/Channel[@chanNum]/ ], 'template' => "__title__ (__channelName__) " . ($c->{'encoder_details'} ? ", Enc: __encoderId__, Chan: __chanNum__ " : '') . "Ends: __endTime__", @@ -333,22 +336,21 @@ my @blocks = ( '&endTime' => sub { my ($value, $vars) = @_; - if ($value =~ /Z$/) { - $value = process_iso_date($value, { date => 0 }); - } else { - $value =~ s/.*T//; - } + if ($value =~ /Z$/) { + $value = process_iso_date($value, { date => 0 }); + } else { + $value =~ s/.*T//; + } - return $value; + return $value; }, }, 'subs' => { - 'find_next' => - sub { - $warn_present ||= 1; - $next_time = $c->{'date'} || 'now'; - } - } + 'find_next' => sub { + $warn_present ||= 1; + $next_time = $c->{'date'} || 'now'; + }, + }, }, # The upcoming recordings. @@ -368,8 +370,8 @@ my @blocks = ( if ($next_time eq 'Never' || Date_Cmp($date, $next_time) < 0) { $next_time = $date }; - } - } + }, + }, }, # Conflicts @@ -404,8 +406,8 @@ my @blocks = ( 'subs' => { 'percent' => sub { calc_disk_space_percentage("$_[0]->{'_total_used'} $_[0]->{'_total_used_unit'}", "$_[0]->{'_total_total'} $_[0]->{'_total_total_unit'}") - }, - } + }, + }, }, # Diskspace, with storage groups @@ -424,8 +426,8 @@ my @blocks = ( 'subs' => { 'percent' => sub { calc_disk_space_percentage("$_[0]->{'drive_total_used'} $_[0]->{'drive_total_used_unit'}", "$_[0]->{'drive_total_total'} $_[0]->{'drive_total_total_unit'}") - } - } + }, + }, }, # Diskspace, with storage groups and sensible XML layout. @@ -443,8 +445,8 @@ my @blocks = ( 'subs' => { 'percent' => sub { calc_disk_space_percentage("$_[0]->{'used'} $_[0]->{'used_unit'}", "$_[0]->{'total'} $_[0]->{'total_unit'}") - } - } + }, + }, }, # Diskspace, with storage groups and sensible XML layout. @@ -463,13 +465,13 @@ my @blocks = ( return ! ( (defined $c->{'display'}{'Disk Space'} && $c->{'display'}{'Disk Space'}) || ($_[1]->{'used'} / $_[1]->{'total'}) * 100 > $c->{'disk_space_warn'}) - } }, + }, 'subs' => { 'percent' => sub { calc_disk_space_percentage("$_[0]->{'used'} $_[0]->{'used_unit'}", "$_[0]->{'total'} $_[0]->{'total_unit'}") - } - } + }, + }, }, # How many hours till the next recording. @@ -487,14 +489,14 @@ my @blocks = ( my $delta = DateCalc($c->{'date'} || 'now', $next_time, \$err, 1); my $seconds = Delta_Format($delta, 'approx', 0, '%sh'); - # If the next recording is more than 1 day in the future, - # print out the days and hours. - my $str; - if ($seconds > 24 * 3600) { - $str = Delta_Format($delta, 0, '%dh Days, %hv Hours'); - } else { - $str = Delta_Format($delta, 0, '%hh Hours, %mv Minutes'); - } + # If the next recording is more than 1 day in the future, + # print out the days and hours. + my $str; + if ($seconds > 24 * 3600) { + $str = Delta_Format($delta, 0, '%dh Days, %hv Hours'); + } else { + $str = Delta_Format($delta, 0, '%hh Hours, %mv Minutes'); + } $str =~ s/\b1 (Day|Hour|Minute)s/1 $1/g; $str =~ s/\b0 (Days|Hours)(, )?//; @@ -506,14 +508,14 @@ my @blocks = ( } return $str; - } }, + }, 'filter' => { 'next_time' => sub { return $_[0] eq 'now' } - }, + }, 'sub' => sub { return substitute_vars($_[0], { 'next_time' => $next_time }); - } + }, }, # Check how much Guide data we have @@ -534,8 +536,8 @@ my @blocks = ( push @alerts, "GUIDE DATA"; return 0; } - }, }, + }, 'rewrite' => { '&guideDays' => sub { if ($_[0] <= $c->{'guide_days_warn'}) { @@ -544,7 +546,7 @@ my @blocks = ( } else { return "$safe$_[0]$normal"; } - }, + }, '/guideThru/' => { 'T\d+:\d+:\d+' => ' ' }, '&guideThru' => sub { if ($_[1]->{'guideDays'} <= $c->{'guide_days_warn'}) { @@ -553,8 +555,8 @@ my @blocks = ( } else { return "$safe$_[0]$normal"; } - }, }, + }, }, { @@ -564,7 +566,7 @@ my @blocks = ( 'xpath' => '//Status/MachineInfo/Guide[@status=""]', 'template' => "${warning}No guide data!${normal}", }, - ); +); ### ### Set some useful variables @@ -804,7 +806,7 @@ sub load_perl_api { if ($verbose) { warn "Failed to load Perl API\n"; print $@; - return undef; + return undef; } } elsif ($verbose) { warn "Loaded Perl API\n"; @@ -898,7 +900,6 @@ sub process_conflicts { foreach my $row (@{$rows{'rows'}}) { my $show; { - # MythTV::Program currently has a slightly broken line with a numeric # comparision. local($^W) = undef; @@ -914,7 +915,7 @@ sub process_conflicts { 'channelName' => $show->{'channame'}, 'inputId' => $show->{'inputid'}, 'chanNum' => $show->{'channum'}, - ); + ); my $str = substitute_vars($block, \%vars); push @lines, decode('UTF-8', $str) @@ -948,7 +949,6 @@ sub process_auto_expire { foreach my $row (reverse @{$rows{'rows'}}) { my $show; { - # MythTV::Program currently has a slightly broken line with a numeric # comparision. local($^W) = undef; @@ -966,7 +966,7 @@ sub process_auto_expire { 'channelName' => $show->{'callsign'}, 'inputId' => $show->{'inputid'}, 'chanNum' => $show->{'chanid'}, - ); + ); my $str = substitute_vars($block, \%vars); push @lines, decode('UTF-8', $str) @@ -1174,7 +1174,7 @@ sub xml_fetch { my $result; warn "Our child has stopped talking to us, kill it off.\n"; do { - kill 9, $pid; + kill 9, $pid; $result = waitpid($pid, WNOHANG); } while $result > 0;