1
0

import/exports to json files:

- fix #5737
 - add import/export or requests
This commit is contained in:
ThomasV
2020-06-05 01:28:00 +02:00
parent 2571669a32
commit 56f4932f10
7 changed files with 70 additions and 47 deletions

View File

@@ -27,7 +27,7 @@ from dns.exception import DNSException
from . import bitcoin
from . import dnssec
from .util import export_meta, import_meta, to_string
from .util import read_json_file, write_json_file, to_string
from .logging import Logger
@@ -52,14 +52,13 @@ class Contacts(dict, Logger):
self.db.put('contacts', dict(self))
def import_file(self, path):
import_meta(path, self._validate, self.load_meta)
def load_meta(self, data):
data = read_json_file(path)
data = self._validate(data)
self.update(data)
self.save()
def export_file(self, filename):
export_meta(self, filename)
def export_file(self, path):
write_json_file(path, self)
def __setitem__(self, key, value):
dict.__setitem__(self, key, value)