summaryrefslogtreecommitdiff
path: root/devtools/testparser.rb
blob: 2b29544374f6a5c520376d68562ff4c5b51ab123 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/ruby -w

# This script takes a lot of .xml files, parse them, and ensure that each of them has at least
# channel : a title, a link
# each item : a title, a link, a content

$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require 'channel'

XMLDIR = '../opml/output/'
DETAILED = true
def do_dir(dir)
  Dir.foreach(dir) do |f|
    next if f !~ /.xml$/
    do_file(XMLDIR + f)
  end
end

def do_file(file)
  print "#{file} : "
  str = File::read(file)
  if str.length == 0
    puts "EMPTY"
    return
  end
  begin
    chan = Channel::new(str)
  rescue UnknownFeedTypeException
    puts "UNKNOWNFEEDTYPE"
    return
  rescue Exception
    puts "EXCEPTION"
    puts $!
    return
  end
  ok = true
  if chan.title.nil?
    ok = false
    puts "Channel Title Empty" if DETAILED
  end
  if chan.link.nil?
    ok = false
    puts "Channel Link Empty" if DETAILED
  end
  if chan.items.length == 0
    ok = false
    puts "Channel Items Empty" if DETAILED
  end
  chan.items.each do |i|
    if i.title.nil?
      ok = false
      puts "Item Title Empty" if DETAILED
    end
    if i.link.nil?
      ok = false
      puts "Item Link Empty" if DETAILED
    end
    if i.content.nil?
      ok = false
      puts "Item Content Empty" if DETAILED
    end
  end
  if ok
    puts "OK"
  else
    puts "ERROR"
  end
end

STDOUT.sync = true
#do_file('../opml/output/112.xml')
do_dir(XMLDIR)
09-10-08Enhance the splash window handling.René 'Necoro' Neumann2-2/+9 2009-10-05Some more stuff to ignoreRené 'Necoro' Neumann1-0/+3 2009-10-05Renamed the ignore fileRené 'Necoro' Neumann1-0/+0 2009-10-05Update NEWSRené 'Necoro' Neumann1-0/+1 2009-10-05Also allow 'unselect all' in the PkgListRené 'Necoro' Neumann1-1/+10 2009-10-05Now have it the sorted way in PkgListsRené 'Necoro' Neumann2-3/+9 2009-10-05Enhanced system.sort_package_list to also sort CPVsRené 'Necoro' Neumann5-27/+38 2009-10-05Added an PkgList window and rewrote UpdateWindow and WorldListWindow to use itRené 'Necoro' Neumann3-39/+63 2009-10-05Add uninstall button and rename to PkgListWindowRené 'Necoro' Neumann1-2/+17 2009-10-05First quick hack to have a world listRené 'Necoro' Neumann3-2/+24