-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add kli import command for importing dot CESR file, add gateway role #921
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
KERI | ||
keri.kli.commands module | ||
|
||
""" | ||
import argparse | ||
import sys | ||
|
||
from hio import help | ||
from hio.base import doing | ||
|
||
from keri.app import habbing | ||
from keri.app.cli.common import existing | ||
from keri.core import coring, serdering, parsing | ||
|
||
logger = help.ogler.getLogger() | ||
|
||
parser = argparse.ArgumentParser(description='Import key events in CESR stream format') | ||
parser.set_defaults(handler=lambda args: export(args), | ||
transferable=True) | ||
parser.add_argument('--name', '-n', help='keystore name and file location of KERI keystore', required=True) | ||
parser.add_argument('--base', '-b', help='additional optional prefix to file location of KERI keystore', | ||
required=False, default="") | ||
parser.add_argument('--passcode', '-p', help='21 character encryption passcode for keystore (is not saved)', | ||
dest="bran", default=None) # passcode => bran | ||
parser.add_argument("--file", help="File of streamed CESR events to import", required=True) | ||
|
||
|
||
def export(args): | ||
""" Command line list credential registries handler | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Docstring is probably from some other functionality? |
||
|
||
""" | ||
|
||
ed = ImportDoer(name=args.name, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should probably be |
||
base=args.base, | ||
bran=args.bran, | ||
file=args.file) | ||
return [ed] | ||
|
||
|
||
class ImportDoer(doing.DoDoer): | ||
|
||
def __init__(self, name, base, bran, file): | ||
self.file = file | ||
|
||
self.hby = existing.setupHby(name=name, base=base, bran=bran) | ||
|
||
doers = [doing.doify(self.exportDo), habbing.HaberyDoer(self.hby)] | ||
|
||
super(ImportDoer, self).__init__(doers=doers) | ||
|
||
def exportDo(self, tymth, tock=0.0): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
""" Export credential from store and any related material | ||
|
||
Parameters: | ||
tymth (function): injected function wrapper closure returned by .tymen() of | ||
Tymist instance. Calling tymth() returns associated Tymist .tyme. | ||
tock (float): injected initial tock value | ||
|
||
Returns: doifiable Doist compatible generator method | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It returns True |
||
|
||
""" | ||
# enter context | ||
self.wind(tymth) | ||
self.tock = tock | ||
_ = (yield self.tock) | ||
|
||
with open(self.file, 'rb') as f: | ||
ims = f.read() | ||
parsing.Parser(kvy=self.hby.kvy, rvy=self.hby.rvy, local=False).parse(ims=ims) | ||
self.hby.kvy.processEscrows() | ||
|
||
self.exit() | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be 'import'