From eed8e30ed278625542d569bc90e2dc3093b6c1a7 Mon Sep 17 00:00:00 2001 From: eto Date: Sat, 12 Jun 2004 04:53:06 +0000 Subject: [PATCH] n.c. --- tools/README | 72 +++++++++++++++++++++++++++-------------- tools/cp-chisedb | 4 --- tools/dump-database.rb | 56 +------------------------------- tools/make-chisedb-tarball.rb | 42 ++++++++++++++---------- tools/management.rb | 41 +++++++++++++++++++++-- tools/scp-chisedb | 4 +++ 6 files changed, 116 insertions(+), 103 deletions(-) delete mode 100755 test/test-ccs.rb delete mode 100755 test/test-db.rb delete mode 100755 tools/cp-chisedb delete mode 100755 tools/dbdumball.rb create mode 100755 tools/scp-chisedb diff --git a/test/test-ccs.rb b/test/test-ccs.rb deleted file mode 100755 index e69de29..0000000 diff --git a/test/test-db.rb b/test/test-db.rb deleted file mode 100755 index e69de29..0000000 diff --git a/tools/README b/tools/README index d0a88a1..6397a64 100755 --- a/tools/README +++ b/tools/README @@ -1,25 +1,47 @@ -¡Ruby/CHISE‚ƈꏏ‚ÉŽg‚¤‚Æ‚¢‚¢‚©‚à‚µ‚ê‚È‚¢“¹‹ïŒQ - -œdbdumball.rb -char-db‚Ì’†‚ÌbdbŒQ‚Ì“à—e‚ð‘S‚Ä.txtƒtƒ@ƒCƒ‹‚Æ‚µ‚Ädump‚µ‚Ü‚·B -‚±‚¤‚·‚é‚ƁAbdb‚Ì“à—e‚ª‚ǂ̂悤‚É‚È‚Á‚Ä‚¢‚é‚©‚ªƒeƒLƒXƒg‚Å‚í‚©‚Á‚Ä•Ö—˜‚Å‚·B -“¯‚¶directory‚ɏ‘‚«o‚µ‚Ü‚·‚̂ŁA‘‚«ž‚Ý‚Ìpermisson‚ª•K—v‚È‚Í‚¸‚Å‚·B - -œmake_ids_db.rb -ƒeƒLƒXƒg‚É‚æ‚éIDSƒtƒ@ƒCƒ‹ŒQ‚ð‘S‚Ä“Ç‚Ý‚±‚݁A -BDB‚Æ‚µ‚Ächar-db/system-char-id/‰º‚ɃZ[ƒu‚µ‚È‚¨‚µ‚Ü‚·B -ŽŸ‰ñ‚©‚ç‚͒ʏí‚Ì‘®«‚̈ê‚‚Ƃµ‚Ä.ids‚ðŽg‚¦‚é‚悤‚É‚È‚è‚Ü‚·B -isolated character‚ðœ‚­‚½‚ß‚É”ñí‚É’x‚­‚È‚Á‚Ä‚¢‚āA1ŽžŠÔ‚­‚ç‚¢‚©‚©‚è‚Ü‚·B - -œmkdbtarball.rb $1 $2 -—á: ./mkdbtarball.rb /usr/local/lib/xemacs-21.4.10/i686-pc-linux/ /var/tmp -char-db‚Ìtarball(char-db.tar.gz)‚ðì‚è‚Ü‚·B -$1‚Échar-db‚Ì‚ ‚è‚©‚ðŽw’肵‚Ü‚·B -‚Ü‚¸$2‚Ì‚Æ‚±‚ë(Žw’è–³‚¯‚ê‚Î/var/tmp)‚Échar-db‚ð‚܂邲‚ƃRƒs[‚µA -ƒtƒ@ƒCƒ‹–¼‚Ì•¶Žš•ÏŠ·‚ðs‚¢Achar-db.tar.gz‚ðì‚è‚Ü‚·B -< > * ? ¨ ( ) + ! -Windows‚̃tƒ@ƒCƒ‹–¼§ŒÀ‚ŁAã‹L‚̍¶‘¤‚Ì•¶Žš‚ªŽg‚¦‚È‚¢‚½‚߁A -‚»‚ê‚ç‚Ì•¶Žš‚ð‰E‘¤‚Ì•¶Žš‚É’u‚«‚©‚¦‚Ä‚©‚çAtar.gz‚ðì‚è‚Ü‚·B - -œtrim_bom.rb -•¶“ª‚É‚ ‚éBOM(byte order mark)‚ðŽæ‚菜‚«‚Ü‚·B +* tools for Chise Character DataBase management + +** make-chisedb-tarball.rb + + Usage: make-chisedb-tarball.rb + +example. + % ./make-chisedb-tarball.rb /usr/local/lib/xemacs-21.4.14/i686-pc-linux + +This makes a tarball (chise-db.tar.gz) of the Chise Character DataBase +files. Set a directory that contains "chise-db" directory to the +first argument. You can input the temp directory to the second arg. +(default value: /var/tmp) + +This tools also rename the characters that contains Windows forbidden +characters. + + < > * ? ¨ ( ) + ! + +** rename-files.rb + +Currently, the directory tree of XEmacs CHISE and the requirement of +libchise is not same. This tool renames the old files trees to the +new file trees. + +** move-obsolete-files.rb + +There are some obsolete features. This tool moves the obsolete files +to a directory. + +** dump-database.rb + +This tool dumps all data of the database to text files. +You can see the inside of the database. It's convenient. + +** make_ids_db.rb + +This tool read the all of IDS test files, parse them and store them to +BDB files. Then, you can use some ids features as normal features. +It's very slow. It takes time almost 1 hour. + +** trim_bom.rb + +This tool remove a BOM (Byte Order Mark) in the head of file. + +==== +by Kouichirou Eto, http://eto.com/ diff --git a/tools/cp-chisedb b/tools/cp-chisedb deleted file mode 100755 index 923fe2e..0000000 --- a/tools/cp-chisedb +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/csh -f -# Copyright (C) 2002-2004 Kouichirou Eto, All rights reserved. - -scp aqua.eto.com:work/chise/ruby/tools/chise-db.tar.gz . diff --git a/tools/dbdumball.rb b/tools/dbdumball.rb deleted file mode 100755 index e69de29..0000000 diff --git a/tools/dump-database.rb b/tools/dump-database.rb index d116f47..5894e92 100755 --- a/tools/dump-database.rb +++ b/tools/dump-database.rb @@ -1,61 +1,7 @@ #!/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 +require "management" man = CHISE::DataBaseManagement.new man.dump_all diff --git a/tools/make-chisedb-tarball.rb b/tools/make-chisedb-tarball.rb index 1fc57cc..68830eb 100755 --- a/tools/make-chisedb-tarball.rb +++ b/tools/make-chisedb-tarball.rb @@ -3,39 +3,47 @@ $LOAD_PATH.unshift("..") require "find" +require "pathname" +require "fileutils" require "chise/util" def usage() print "Usage: make-chisedb-tarball.rb \n" - print "% ./make-chisedb-tarball.rb /usr/local/lib/xemacs-21.4.14/i686-pc-linux /var/tmp\n" + print "% ./make-chisedb-tarball.rb /usr/local/lib/xemacs-21.4.14/i686-pc-linux /var/tmp\n" exit end def main(argv) usage if argv.length < 1 dir = argv.shift - unless FileTest.directory?(dir+"/chise-db") - print "no chise-db here. #{dir}\n" + path = dir.path + dbpath = dir+"chise-db" + unless dbpath.directory? + print "no chise-db here. #{dbpath.to_s}\n" usage end tmpdir = argv.shift tmpdir = "/var/tmp" if tmpdir.nil? + tmppath = tmpdir.path orgdir = Dir.pwd - Dir.chdir(tmpdir) # “K“–‚Èdir‚Ɉړ®‚µ‚Ä‚©‚ç - system "cp -a #{dir}/chise-db ." # ‚Ü‚¸‚»‚Ìdirectory‚É–â“š–³—p‚Å‘S•”ƒRƒs[‚·‚éB - - Find.find("."){|f| - if f =~ /([*?<>])/ # Windows‚É‚¨‚¯‚é‹ÖŽ~•¶Žš‚ªŠÜ‚Ü‚ê‚Ä‚¢‚½‚çA’uŠ·‚·‚é - nf = CHISE.unix_to_win(f) - cmd = "mv '#{f}' '#{nf}'" - #print cmd, "\n" - system cmd - end - } - system "tar czf chise-db.tar.gz chise-db" - system "mv chise-db.tar.gz #{orgdir}" - system "rm -rf #{tmpdir}/chise-db" + tmppath.chdir { + system "cp -a #{dir}/chise-db ." # copy all of the chise-db to the dir. + + ".".path.find {|f| + if f =~ /([*?<>])/ # escape for Windows forbidden characters. + nf = f.escape_win_filename + cmd = "mv '#{f}' '#{nf}'" + #print cmd, "\n" + system cmd + end + } + + system "tar czf chise-db.tar.gz chise-db" + system "mv chise-db.tar.gz #{orgdir}" + system "rm -rf #{tmpdir}/chise-db" + + } end main(ARGV) diff --git a/tools/management.rb b/tools/management.rb index 820a960..284ed6e 100755 --- a/tools/management.rb +++ b/tools/management.rb @@ -1,6 +1,7 @@ # Copyright (C) 2002-2004 Kouichirou Eto, All rights reserved. $LOAD_PATH.unshift("..") +require "chise/char" require "pathname" require "fileutils" require "chise/config" @@ -10,8 +11,44 @@ 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.escape.escape_win_filename + txt = f.to_s+".txt" + #qp f.to_s, 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 diff --git a/tools/scp-chisedb b/tools/scp-chisedb new file mode 100755 index 0000000..923fe2e --- /dev/null +++ b/tools/scp-chisedb @@ -0,0 +1,4 @@ +#!/bin/csh -f +# Copyright (C) 2002-2004 Kouichirou Eto, All rights reserved. + +scp aqua.eto.com:work/chise/ruby/tools/chise-db.tar.gz . -- 1.7.10.4