X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fruby.git;a=blobdiff_plain;f=tools%2Fdump-database.rb;fp=tools%2Fdump-database.rb;h=d116f476bbb577a097f30f528c642dd84179a053;hp=0000000000000000000000000000000000000000;hb=ffce8c4eb4a667debd47bfe237de4588414b0bb4;hpb=5b25cdbb3d6d0d4621f1ecf82a12b4a3a6f8edba diff --git a/tools/dump-database.rb b/tools/dump-database.rb new file mode 100755 index 0000000..d116f47 --- /dev/null +++ b/tools/dump-database.rb @@ -0,0 +1,61 @@ +#!/usr/bin/env ruby +# Copyright (C) 2002-2004 Kouichirou Eto, All rights reserved. + +$LOAD_PATH.unshift("..") +require "chise/char" +require "chise/qp" + +module CHISE + class DataBaseManagement + def dump_all + #CharDB.instance.dump_all() + #CodesysDB.instance.dump_all() + + cd = ChiseDB.instance + path = cd.location+"character/feature" + + cd.each_feature {|f| + ft = cd.get_feature(f) + h = {} + ft.each {|k, v| + h[k] = v + } + + f = f.path + f = f.escape + f = f.escape_win_filename + txt = f.to_s+".txt" + qp f, txt + t = path+txt + + t.open("wb"){|out| + h.sort.each {|k, v| + out.printf("%s\t%s\n", k, v) + } + } + + ft.close + } + end + + def dump_db(t) + db = get(t) + return nil unless db + file = get_filename(t) + open("#{file}.txt", "w"){|out| + # out.binmode.sync = true + ar = db.to_a + ar.map! {|k, v| [to_num(k), to_num(v)] } + ar.sort.each {|k, v| + out.printf("%s\t%s\n", k, v) + } + } + true + end + + + end +end + +man = CHISE::DataBaseManagement.new +man.dump_all