From 5333fa06f5f611477a122c90d887cc14c87c2a94 Mon Sep 17 00:00:00 2001 From: neingeist Date: Wed, 19 Apr 2006 23:15:16 +0000 Subject: [PATCH] jajaja --- neinomat-gpn-kategorien | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 neinomat-gpn-kategorien diff --git a/neinomat-gpn-kategorien b/neinomat-gpn-kategorien new file mode 100755 index 0000000..328b042 --- /dev/null +++ b/neinomat-gpn-kategorien @@ -0,0 +1,33 @@ +#!/usr/bin/env ruby +$:.unshift('vendor/ruby-mediawiki/lib') +$:.unshift('vendor/htree') +require 'mediawiki/dotfile' +@wiki = MediaWiki.dotfile(nil,'entropia') + +def is_redirect?(title) + @wiki.article(title).text =~ /REDIRECT/ +end + +def check_category(title_re, category) + category_articles = @wiki.category(category).articles + missing = [] + + @wiki.allpages.delete_if { |t| t !~ title_re }.each do |title| + if !is_redirect?(title) && !category_articles.member?(title) + missing << title + end + end + + if missing.size > 0 + puts "Folgenden Artikel fehlt die Kategorie: #{category}\n" + missing.each do |t| + puts t.chomp + end + puts + end +end + +check_category(/GPN/, "GPN") +(1..5).each do |n| + check_category(/GPN#{n}/, "GPN#{n}") +end