diff options
author | Magnus Ahltorp <map@kth.se> | 2016-07-08 16:51:55 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2016-07-11 15:37:01 +0200 |
commit | b6ce64e114022ea23668cd69ce0ef7517dbe68ad (patch) | |
tree | 9c1b3a3e32e7e35bfd57fa98272b367e1545d403 /tools/mergetools.py | |
parent | e43a199b241d74f7a5ad046139a318576cdf21b6 (diff) |
Added permdb support to merge
Diffstat (limited to 'tools/mergetools.py')
-rw-r--r-- | tools/mergetools.py | 31 |
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) |