summaryrefslogtreecommitdiff
path: root/tools/mergetools.py
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2016-07-08 16:51:55 +0200
committerMagnus Ahltorp <map@kth.se>2016-07-08 16:51:55 +0200
commit9039104a2203e3467a2420348e5cee43eb5bd5af (patch)
tree6f6e565cf504aaab6b43fb60734b89142dc25477 /tools/mergetools.py
parented94e0682912a8ee16cb5a1427166c3e77b51b50 (diff)
Added permdb support to merge
Diffstat (limited to 'tools/mergetools.py')
-rw-r--r--tools/mergetools.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/mergetools.py b/tools/mergetools.py
index ec4fd2a..80fbf0b 100644
--- a/tools/mergetools.py
+++ b/tools/mergetools.py
@@ -10,6 +10,10 @@ import json
import yaml
import argparse
import requests
+try:
+ import permdb
+except ImportError:
+ pass
from certtools import get_leaf_hash, http_request, get_leaf_hash
def parselogrow(row):
@@ -409,3 +413,30 @@ def parse_args():
localconfig = yaml.load(open(args.localconfig))
return (args, config, localconfig)
+
+def perm(dbtype, path):
+ if dbtype == "filedb":
+ return FileDB(path)
+ elif dbtype == "permdb":
+ return PermDB(path)
+ assert False
+
+class FileDB:
+ def __init__(self, path):
+ self.path = path
+ def get(self, key):
+ return read_chain(self.path, key)
+ def add(self, key, value):
+ return write_chain(key, value, self.path)
+ def commit(self):
+ pass
+
+class PermDB:
+ def __init__(self, path):
+ self.permdbobj = permdb.alloc(path)
+ def get(self, key):
+ return permdb.getvalue(self.permdbobj, key)
+ def add(self, key, value):
+ return permdb.addvalue(self.permdbobj, key, value)
+ def commit(self):
+ permdb.committree(self.permdbobj)