From ad01c5110ebeeb9db918c595a3bc1a06c4362fc2 Mon Sep 17 00:00:00 2001 From: Ward Wouts Date: Tue, 30 Apr 2002 15:32:28 +0000 Subject: [PATCH] remove cruft allow comments in config mark articles if there was a problem downloading them (don't keep trying stuff that won't work) --- trunk/ripnews/ripnews.rb | 64 ++++++++-------------------------------- 1 file changed, 13 insertions(+), 51 deletions(-) diff --git a/trunk/ripnews/ripnews.rb b/trunk/ripnews/ripnews.rb index 874267d..9edbe68 100755 --- a/trunk/ripnews/ripnews.rb +++ b/trunk/ripnews/ripnews.rb @@ -11,7 +11,7 @@ require 'news/newsrc' ########################################################################### -Debuglevel = 1 +Debuglevel = 0 def save_file(dir, name, data) print "savename: #{name}\n" if Debuglevel > 1 @@ -69,7 +69,6 @@ def tmp_file(dir) end end - def parse_options(options) begin opts = GetoptLong.new( @@ -94,29 +93,6 @@ def parse_options(options) return options end -#def read_config(options) -# unless options.has_key?("-c") -# options["-c"]=".ripnewsrc" -# end -# begin -# config = IO.readlines("#{options[\"-c\"]}") -# for i in config -# if i =~ /^OPT_(.)=?(.*)$/ -# options["-#{$1}"]=$2 unless -# options.has_key?("-#{$1}") -# else -# i =~ /([^=]*)=(.*)/ -# options["#{$1}"]=$2 -# end -# print "#{$1}=", options["#{$1}"], "\n" if Debuglevel > 1 -# end -# rescue -# print "Coudn't open config file: #{options[\"-c\"]}\n" -# exit -# end -# return options -#end - def parse_config(default = {}) file = File.new("#{default[\"-c\"]}") lines = file.readlines @@ -125,7 +101,11 @@ def parse_config(default = {}) group = "" config = {} - lines.collect!{|x| x.sub!(/^\s*/, ""); x.chomp} + lines.collect!{|x| + x.sub!(/^\s*/, "") + x.sub!(/\#.*$/, "") + x.chomp + } while i < lines.length line = lines[i] while line.sub!(/\s*\\$/, "") != nil @@ -201,22 +181,6 @@ def parse_config(default = {}) return config end -#def check_options(options) -# if (Debuglevel > 1) -# for i in options.keys -# print "Opt: #{i} Value: #{options[i]}\n" -# end -# end -# unless options.has_key?("-I") -# print "No inclusions given. Won't match anything.\n" -# exit -# end -# unless options.has_key?("DATADIR") -# options["DATADIR"] ="." -# end -## exit # zeer tijdelijk voor snel testen -#end - def check_config(config) config.each_key {|i| unless config[i].has_key?("-I") @@ -231,7 +195,6 @@ end defaults = {'-c' => '.ripnewsrc'} defaults = parse_options(defaults) -#options = read_config(options) config = parse_config(defaults) check_config(config) @@ -262,7 +225,7 @@ for group in config.keys if i =~ /#{config[group]["-I"]}/i print "Match: #{i}\n" if Debuglevel > 0 if articles.group_complete(i) - print "Complete: #{i}\n" if Debuglevel > 0 + print " Fetching: #{i}\n" if config[group].has_key?("TMPDIR") file, fullname = tmp_file(config[group]["TMPDIR"]) fileout, fullnameout = tmp_file(config[group]["TMPDIR"]) @@ -283,24 +246,23 @@ for group in config.keys if mode print "mode: #{mode}\n" if Debuglevel > 0 print "filename: #{filename}\n" - if config[group].has_key?("-L") + if config[group].has_key?("-L") and config[group]["-L"] print "longname\n" if Debuglevel > 1 save_file("#{config[group]["DATADIR"]}/#{group}", i, body) else print "shortname\n" if Debuglevel > 1 save_file("#{config[group]["DATADIR"]}/#{group}", filename, body) end - marked = articles.get_group_ids(i) - newsrc.mark_list(group, marked) - newsrc.save - #marked.collect!{|x| print "marked: #{x}\n"} end + marked = articles.get_group_ids(i) + newsrc.mark_list(group, marked) + newsrc.save + #marked.collect!{|x| print "marked: #{x}\n"} # rm file & fileout File.delete(fullname) else - print "Not complete: #{i}\n" + print " Not complete: #{i}\n" end - print "\n" end end articles.quit