summaryrefslogtreecommitdiff
path: root/tools/mergetools.py
diff options
context:
space:
mode:
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)