1
0
Fork 0
This repository has been archived on 2019-12-19. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
neinomaten/neinomat-gpn-fahrplan

59 lines
1.1 KiB
Text
Raw Normal View History

2007-05-31 15:53:34 +00:00
#!/usr/bin/env ruby
$:.unshift('vendor/ruby-mediawiki/lib')
require 'mediawiki/dotfile'
@wiki = MediaWiki.dotfile(nil,'entropia')
2008-07-03 21:54:30 +00:00
roh = @wiki.article("Vorlage:GPN7:Fahrplan").text
2007-05-31 15:53:34 +00:00
def cleanse (t)
t.gsub(/\[\[.*\|(.*)\]\]/, '\1')
end
uhrzeit = nil
titel1 = nil
titel2 = nil
2007-05-31 16:39:48 +00:00
titel3 = nil
2007-05-31 15:53:34 +00:00
tag = 1
roh.split("\n").each do |line|
2008-07-03 21:54:30 +00:00
if line =~ /^\| *(.*:[0-9]+) *$/
2007-05-31 15:53:34 +00:00
if uhrzeit
2008-07-03 21:54:30 +00:00
puts "#{tag} #{uhrzeit} ÜBERALL #{titel1}" if titel1
puts "#{tag} #{uhrzeit} NIRGENDS #{titel2}" if titel2
puts "#{tag} #{uhrzeit} IRGENDWO #{titel3}" if titel3
2007-05-31 15:53:34 +00:00
end
if uhrzeit && $1 < uhrzeit
tag += 1
end
uhrzeit = $1
titel1 = nil
titel2 = nil
2007-05-31 16:39:48 +00:00
titel3 = nil
2008-07-03 21:54:30 +00:00
elsif line =~ /^\|(?: *(?:valign=top|align=center) *\|)? *('''(.*)'''|.*(GOTO).*)\s*$/
2007-05-31 16:39:48 +00:00
# yum
2007-05-31 16:40:58 +00:00
if $3 == "GOTO"
2007-05-31 16:43:27 +00:00
# *frickl*
if line =~ /colspan=2/
titel1 = ""
end
2007-05-31 16:39:48 +00:00
t = ""
else
2007-05-31 16:40:58 +00:00
t = $2
2007-05-31 16:39:48 +00:00
end
2007-05-31 15:53:34 +00:00
if titel1 == nil
2007-05-31 16:39:48 +00:00
titel1 = cleanse(t)
elsif titel2 == nil
titel2 = cleanse(t)
else
titel3 = cleanse(t)
2007-05-31 15:53:34 +00:00
end
end
end