+++ /dev/null
-# Copyright (C) 2002-2004 Kouichirou Eto, All rights reserved.
-
-$LOAD_PATH.unshift("..")
-require "chise/char"
-require "pathname"
-require "fileutils"
-require "chise/config"
-require "chise/util"
-require "chise/qp"
-
-module CHISE
- class DataBaseManagement
- def 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
-
- class DataBaseFileManagement
-
- # from specs/char-atr.ja.txt
- OBSOLETE_FEATURES = "
-cns-radical
-cns-radical?
-kangxi-radical
-daikanwa-radical
-
-cns-strokes
-kangxi-strokes
-daikanwa-strokes
-shinjigen-1-radical
-gb-original-radical
-japanese-strokes
-jis-strokes-a
-jisx0208-strokes
-unicode-strokes
-
-cns-total-strokes
-
-non-morohashi
-
-=>ucs*
-#=>mojikyo
-#=mojikyo
-->identical
-
-ancient-ideograph-of
-ancient-char-of-shinjigen-1
-original-ideograph-of
-original-char-of-shinjigen-1
-vulgar-ideograph-of
-vulgar-char-of-shinjigen-1
-ideographic-variants
-variant-of-shinjigen-1
-
-iso-10646-comment
-".split
-
- def initialize()
- # @opt = {:noop=>true, :verbose=>true}
- @opt = {:verbose=>true}
- end
-
- def move_obsolete_files
- fpath = Config.instance.db_dir.path+"system-char-id"
- fpath.chdir {
- opath = "obsolete".path
- opath.mkdir unless opath.directory?
-
- OBSOLETE_FEATURES.each {|attr|
- next if attr =~ /^#/
- f = attr.path
- f = f.normalize_filename
- FileUtils.mv(f.to_s, opath.to_s, @opt) if f.exist?
- f = f+".txt"
- FileUtils.mv(f.to_s, opath.to_s, @opt) if f.exist?
- }
- }
- end
-
- def rename_files
- path = Config.instance.db_dir.path
-
- nfpath = path+"character/feature"
- FileUtils.mkdir_p(nfpath.to_s, @opt) unless nfpath.directory?
-
- fpath = path+"system-char-id"
- fpath.each_entry {|f|
- next if /\A\./ =~ f
- FileUtils.mv((fpath+f).to_s, nfpath.to_s, @opt)
- }
-
- ncpath = path+"character/by_feature"
- FileUtils.mkdir_p(ncpath.to_s, @opt) unless ncpath.directory?
-
- path.each_entry {|f|
- next if /\A\./ =~ f
- next if f.to_s == "character"
- d = path + f
- next unless d.directory?
- ff = d + "system-char-id"
- if ff.exist?
- FileUtils.mv(ff.to_s, (ncpath+f).to_s, @opt)
- end
- }
- end
- end
-end