]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
[registry] rbotdb script now imports tc databases
authorMatthias H <apoc@sixserv.org>
Mon, 24 Feb 2014 21:50:16 +0000 (22:50 +0100)
committerMatthias H <apoc@sixserv.org>
Mon, 24 Feb 2014 21:50:16 +0000 (22:50 +0100)
bin/rbotdb

index 14d61e47539fea6f2d415d273d50897bda8251f0..804059f41254030a54aef138ad5ba530f865770a 100755 (executable)
@@ -227,6 +227,8 @@ class ImportRegistry
       case @type
       when :dbm
         write_dbm(file, hash)
+      when :tc
+        write_tc(file, hash)
       when :daybreak
         write_daybreak(file, hash)
       end
@@ -242,6 +244,19 @@ class ImportRegistry
     db.close
   end
 
+  def write_tc(file, data)
+    db = TokyoCabinet::BDB.new
+    db.open(file + '.tdb',
+          TokyoCabinet::BDB::OREADER | 
+          TokyoCabinet::BDB::OCREAT | 
+          TokyoCabinet::BDB::OWRITER)
+    data.each_pair do |key, value|
+      db[key] = value
+    end
+    db.optimize
+    db.close
+  end
+
   def write_daybreak(file, data)
     db = Daybreak::DB.new(file + '.db')
     data.each_pair do |key, value|