Changeset 431

Show
Ignore:
Timestamp:
01/09/07 16:50:19 (6 years ago)
Author:
lincoln
Message:

convert reconciler_mk2 to Storable

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • reconcilers/reconciler_mk2

    r421 r431  
    9595 
    9696my $progname = "reconciler_mk2"; 
    97 my $version = "0.18"; 
     97my $version = "0.19"; 
    9898 
    9999use LWP::UserAgent; 
     
    104104use Data::Dumper; 
    105105use Compress::Zlib; 
     106use Storable; 
    106107 
    107108#### reconciler settings #### 
     
    219220my $opt = { }; 
    220221$opt->{output_file} =           "output.xmltv"; 
    221 $opt->{config_file} =           $progname.".config"; 
     222$opt->{old_config_file} =       $progname.".config"; 
     223$opt->{config_file} =           $progname.".storable.config"; 
    222224$opt->{log_file} =              $progname.".log"; 
    223225$opt->{alt_title_file} =        $progname.".alt_title.log"; 
     
    232234        'channels_file=s'       => \$opt->{channels_file}, 
    233235        'preftitle=s'           => \$opt->{preftitle}, 
     236        'old-config-file=s'     => \$opt->{old_config_file}, 
    234237        'config-file=s'         => \$opt->{config_file}, 
    235238        'log=s'                 => \$opt->{log_file}, 
     
    243246 
    244247        'print_listing'         => \$reclogic{debug_print_programme_list}, 
     248        'dump_config'           => \$opt->{dump_config}, 
    245249 
    246250        'help'                  => \$opt->{help}, 
     
    314318&log(1,"alternate titles to $opt->{alt_title_file}") unless $opt->{nolog}; 
    315319 
    316 &read_config_file($opt->{config_file},0) if ($opt->{config_file}); 
    317  
     320# convert from old Data::Dumper to newer Storable config file 
     321if ((defined $opt->{old_config_file}) && (-r $opt->{old_config_file})) { 
     322        &read_config_file($opt->{old_config_file},0) if ($opt->{old_config_file}); 
     323        &write_config_file; 
     324        unlink($opt->{old_config_file}); 
     325} 
     326 
     327&read_storable_file($opt->{config_file}) if ($opt->{config_file}); 
    318328&show_settings; 
    319329 
     
    360370 
    361371###################################################################################################### 
    362 # read settings 
     372# read settings (used for old config file and shepherd .conf files) 
    363373 
    364374sub read_config_file 
     
    373383} 
    374384 
     385###################################################################################################### 
     386# used for reconciler new style config file 
     387 
     388sub read_storable_file 
     389{ 
     390        my($file,$die_on_failure) = @_; 
     391        if (!(-r $file)) { 
     392                die "file $file could not be read.  aborting.\n" if $die_on_failure; 
     393                return; 
     394        } 
     395 
     396        my $store = Storable::retrieve($file); 
     397        $setting_override = $store->{settings_override}; 
     398        $title_xlate_table = $store->{title_xlate_table}; 
     399        $title_history = $store->{title_history}; 
     400 
     401        if (defined $opt->{dump_config}) { 
     402                print Dumper($store); 
     403                exit(0); 
     404        } 
     405} 
    375406 
    376407###################################################################################################### 
     
    387418        } 
    388419 
    389         open(CONF, ">$opt->{config_file}") || die "cannot write to $opt->{config_file}: $!"; 
    390         print CONF Data::Dumper->Dump( 
    391                 [$setting_override,  $title_xlate_table,  $title_history], 
    392                 ["setting_override", "title_xlate_table", "title_history" ]); 
    393         close CONF; 
     420        my $store; 
     421        $store->{settings_override} = $setting_override; 
     422        $store->{title_xlate_table} = $title_xlate_table; 
     423        $store->{title_history} = $title_history; 
     424 
     425        Storable::store($store, $opt->{config_file}); 
    394426        &log(1,(sprintf "updated configuration file %s.\n",$opt->{config_file})); 
    395427} 
  • status

    r429 r431  
    1111grabber         yahoo7web           0.04 
    1212grabber         ten_website         0.02 
    13 reconciler      reconciler_mk2      0.18 
    14 postprocessor   imdb_augment_data   0.07 
     13reconciler      reconciler_mk2      0.19 
     14postprocessor   imdb_augment_data   0.08 
    1515postprocessor   augment_timezone    0.05