Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added iso_639_leecher

git-svn-id: svn://78.47.249.61/ruby-mediawiki/trunk@48 ba9c31aa-a806-0410-9a81-9f13d15ee83b
  • Loading branch information...
commit bd061908eec3e89a31a883d7a059db8c8f4cbaaf 1 parent 066aba0
sven authored
Showing with 44 additions and 1 deletion.
  1. +41 −0 apps/iso_639_leecher.rb
  2. +3 −1 apps/rdoc_to_wiki.rb
View
41 apps/iso_639_leecher.rb
@@ -0,0 +1,41 @@
+#!/usr/bin/env ruby
+
+$:.unshift('../lib')
+
+require 'mediawiki/dotfile'
+require 'mediawiki/table'
+require 'momomoto/momomoto'
+require 'momomoto/tables'
+require 'momomoto/bot_login'
+
+ ENV['MEDIAWIKI_WIKI'] = 'wikipedia_de'
+
+ db_config = YAML.load_file('db_config.yml')['development']
+ Momomoto::Base.connect(db_config)
+ Momomoto::Bot_login.authorize('ui_tagger')
+
+ wiki = MediaWiki.dotfile
+ page = wiki.article('ISO 639', 3)
+ t = MediaWiki::Table.parse( page.text )
+
+ t.shift
+
+ t.each do | row |
+ row[2].split( '/' ).each do | iso_code |
+ id = Momomoto::Language.find({:iso_639_code=>iso_code})
+ next unless id.length == 1
+ match = row[0].match /\[\[(.*\|)?(.+)\]\]/
+ name = match[2]
+
+ local = Momomoto::Language_localized.find({:language_id=>id.language_id,:translated_id=>144})
+ if local.length == 0 && name != ''
+ local.create
+ local.language_id = id.language_id
+ local.translated_id = 144
+ local.name = name
+ local.write
+ end
+
+ end
+ end
+
View
4 apps/rdoc_to_wiki.rb
@@ -6,6 +6,8 @@
$:.unshift('../lib')
require 'mediawiki/dotfile'
+ENV['MEDIAWIKI_WIKI'] = 'astrobot'
+
def find(dir, &block)
Dir.foreach(dir) { |file|
@@ -97,7 +99,7 @@ def wiki_format(flow)
}
}
-if false # Dry run?
+if true # Dry run?
puts text
exit
end
Please sign in to comment.
Something went wrong with that request. Please try again.