remove cruft
allow comments in config mark articles if there was a problem downloading them (don't keep trying stuff that won't work)
This commit is contained in:
parent
2703d61cf2
commit
ad01c5110e
1 changed files with 13 additions and 51 deletions
|
|
@ -11,7 +11,7 @@ require 'news/newsrc'
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
|
||||||
Debuglevel = 1
|
Debuglevel = 0
|
||||||
|
|
||||||
def save_file(dir, name, data)
|
def save_file(dir, name, data)
|
||||||
print "savename: #{name}\n" if Debuglevel > 1
|
print "savename: #{name}\n" if Debuglevel > 1
|
||||||
|
|
@ -69,7 +69,6 @@ def tmp_file(dir)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def parse_options(options)
|
def parse_options(options)
|
||||||
begin
|
begin
|
||||||
opts = GetoptLong.new(
|
opts = GetoptLong.new(
|
||||||
|
|
@ -94,29 +93,6 @@ def parse_options(options)
|
||||||
return options
|
return options
|
||||||
end
|
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 = {})
|
def parse_config(default = {})
|
||||||
file = File.new("#{default[\"-c\"]}")
|
file = File.new("#{default[\"-c\"]}")
|
||||||
lines = file.readlines
|
lines = file.readlines
|
||||||
|
|
@ -125,7 +101,11 @@ def parse_config(default = {})
|
||||||
group = ""
|
group = ""
|
||||||
config = {}
|
config = {}
|
||||||
|
|
||||||
lines.collect!{|x| x.sub!(/^\s*/, ""); x.chomp}
|
lines.collect!{|x|
|
||||||
|
x.sub!(/^\s*/, "")
|
||||||
|
x.sub!(/\#.*$/, "")
|
||||||
|
x.chomp
|
||||||
|
}
|
||||||
while i < lines.length
|
while i < lines.length
|
||||||
line = lines[i]
|
line = lines[i]
|
||||||
while line.sub!(/\s*\\$/, "") != nil
|
while line.sub!(/\s*\\$/, "") != nil
|
||||||
|
|
@ -201,22 +181,6 @@ def parse_config(default = {})
|
||||||
return config
|
return config
|
||||||
end
|
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)
|
def check_config(config)
|
||||||
config.each_key {|i|
|
config.each_key {|i|
|
||||||
unless config[i].has_key?("-I")
|
unless config[i].has_key?("-I")
|
||||||
|
|
@ -231,7 +195,6 @@ end
|
||||||
|
|
||||||
defaults = {'-c' => '.ripnewsrc'}
|
defaults = {'-c' => '.ripnewsrc'}
|
||||||
defaults = parse_options(defaults)
|
defaults = parse_options(defaults)
|
||||||
#options = read_config(options)
|
|
||||||
config = parse_config(defaults)
|
config = parse_config(defaults)
|
||||||
check_config(config)
|
check_config(config)
|
||||||
|
|
||||||
|
|
@ -262,7 +225,7 @@ for group in config.keys
|
||||||
if i =~ /#{config[group]["-I"]}/i
|
if i =~ /#{config[group]["-I"]}/i
|
||||||
print "Match: #{i}\n" if Debuglevel > 0
|
print "Match: #{i}\n" if Debuglevel > 0
|
||||||
if articles.group_complete(i)
|
if articles.group_complete(i)
|
||||||
print "Complete: #{i}\n" if Debuglevel > 0
|
print " Fetching: #{i}\n"
|
||||||
if config[group].has_key?("TMPDIR")
|
if config[group].has_key?("TMPDIR")
|
||||||
file, fullname = tmp_file(config[group]["TMPDIR"])
|
file, fullname = tmp_file(config[group]["TMPDIR"])
|
||||||
fileout, fullnameout = tmp_file(config[group]["TMPDIR"])
|
fileout, fullnameout = tmp_file(config[group]["TMPDIR"])
|
||||||
|
|
@ -283,24 +246,23 @@ for group in config.keys
|
||||||
if mode
|
if mode
|
||||||
print "mode: #{mode}\n" if Debuglevel > 0
|
print "mode: #{mode}\n" if Debuglevel > 0
|
||||||
print "filename: #{filename}\n"
|
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
|
print "longname\n" if Debuglevel > 1
|
||||||
save_file("#{config[group]["DATADIR"]}/#{group}", i, body)
|
save_file("#{config[group]["DATADIR"]}/#{group}", i, body)
|
||||||
else
|
else
|
||||||
print "shortname\n" if Debuglevel > 1
|
print "shortname\n" if Debuglevel > 1
|
||||||
save_file("#{config[group]["DATADIR"]}/#{group}", filename, body)
|
save_file("#{config[group]["DATADIR"]}/#{group}", filename, body)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
marked = articles.get_group_ids(i)
|
marked = articles.get_group_ids(i)
|
||||||
newsrc.mark_list(group, marked)
|
newsrc.mark_list(group, marked)
|
||||||
newsrc.save
|
newsrc.save
|
||||||
#marked.collect!{|x| print "marked: #{x}\n"}
|
#marked.collect!{|x| print "marked: #{x}\n"}
|
||||||
end
|
|
||||||
# rm file & fileout
|
# rm file & fileout
|
||||||
File.delete(fullname)
|
File.delete(fullname)
|
||||||
else
|
else
|
||||||
print " Not complete: #{i}\n"
|
print " Not complete: #{i}\n"
|
||||||
end
|
end
|
||||||
print "\n"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
articles.quit
|
articles.quit
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue