Skip to content

Commit

Permalink
setting formatting to black formatter to improve future PR merges
Browse files Browse the repository at this point in the history
Signed-off-by: 2byrds <[email protected]>
  • Loading branch information
2byrds committed Jul 22, 2024
1 parent 74c5b28 commit ea53e90
Show file tree
Hide file tree
Showing 12 changed files with 710 additions and 504 deletions.
62 changes: 43 additions & 19 deletions src/dkr/app/cli/commands/did/keri/resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,51 @@

from dkr.core import didding

parser = argparse.ArgumentParser(description='Resolve a did:keri DID')
parser.set_defaults(handler=lambda args: handler(args),
transferable=True)
parser.add_argument('-n', '--name',
action='store',
default="dkr",
help="Name of controller. Default is dkr.")
parser.add_argument('--base', '-b', help='additional optional prefix to file location of KERI keystore',
required=False, default="")
parser.add_argument('--passcode', help='22 character encryption passcode for keystore (is not saved)',
dest="bran", default=None) # passcode => bran
parser.add_argument("--did", "-d", help="DID to resolve (did:keri method)", required=True)
parser.add_argument("--oobi", "-o", help="OOBI to use for resolving the DID", required=False)
parser.add_argument("--meta", "-m", help="Whether to include metadata (True), or only return the DID document (False)", type=bool, required=False, default=None)
parser = argparse.ArgumentParser(description="Resolve a did:keri DID")
parser.set_defaults(handler=lambda args: handler(args), transferable=True)
parser.add_argument(
"-n",
"--name",
action="store",
default="dkr",
help="Name of controller. Default is dkr.",
)
parser.add_argument(
"--base",
"-b",
help="additional optional prefix to file location of KERI keystore",
required=False,
default="",
)
parser.add_argument(
"--passcode",
help="22 character encryption passcode for keystore (is not saved)",
dest="bran",
default=None,
) # passcode => bran
parser.add_argument(
"--did", "-d", help="DID to resolve (did:keri method)", required=True
)
parser.add_argument(
"--oobi", "-o", help="OOBI to use for resolving the DID", required=False
)
parser.add_argument(
"--meta",
"-m",
help="Whether to include metadata (True), or only return the DID document (False)",
type=bool,
required=False,
default=None,
)


def handler(args):
hby = existing.setupHby(name=args.name, base=args.base, bran=args.bran)
hbyDoer = habbing.HaberyDoer(habery=hby) # setup doer
obl = oobiing.Oobiery(hby=hby)
res = KeriResolver(hby=hby, hbyDoer=hbyDoer, obl=obl, did=args.did, oobi=args.oobi, meta=args.meta)
res = KeriResolver(
hby=hby, hbyDoer=hbyDoer, obl=obl, did=args.did, oobi=args.oobi, meta=args.meta
)
return [res]


Expand All @@ -55,7 +79,7 @@ def __init__(self, hby, hbyDoer, obl, did, oobi, meta):
def resolve(self, tymth, tock=0.0, **opts):
self.wind(tymth)
self.tock = tock
_ = (yield self.tock)
_ = yield self.tock

aid = didding.parseDIDKeri(self.did)
print(f"From arguments got aid: {aid}", file=sys.stderr)
Expand All @@ -68,13 +92,13 @@ def resolve(self, tymth, tock=0.0, **opts):
while self.hby.db.roobi.get(keys=(self.oobi,)) is None:
_ = yield tock

didresult = didding.generateDIDDoc(self.hby, did=self.did, aid=aid, oobi=self.oobi, meta=True)
didresult = didding.generateDIDDoc(
self.hby, did=self.did, aid=aid, oobi=self.oobi, meta=True
)
dd = didresult[didding.DD_FIELD]
result = didresult if self.meta else dd
data = json.dumps(result, indent=2)

print(data)
self.remove(self.toRemove)
return result


91 changes: 55 additions & 36 deletions src/dkr/app/cli/commands/did/keri/resolver-service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,51 @@

from dkr.core import resolving

parser = argparse.ArgumentParser(description='Expose did:keri resolver as an HTTP web service')
parser.set_defaults(handler=lambda args: launch(args),
transferable=True)
parser.add_argument('-p', '--http',
action='store',
default=7678,
help="Port on which to listen for did:keri resolution requests. Defaults to 7678")
parser.add_argument('-n', '--name',
action='store',
default="dkr",
help="Name of controller. Default is dkr.")
parser.add_argument('--base', '-b', help='additional optional prefix to file location of KERI keystore',
required=False, default="")
parser.add_argument('--passcode', help='22 character encryption passcode for keystore (is not saved)',
dest="bran", default=None) # passcode => bran
parser.add_argument("--config-dir",
"-c",
dest="configDir",
help="directory override for configuration data",
default=None)
parser.add_argument('--config-file',
dest="configFile",
action='store',
default=None,
help="configuration filename override")
parser = argparse.ArgumentParser(
description="Expose did:keri resolver as an HTTP web service"
)
parser.set_defaults(handler=lambda args: launch(args), transferable=True)
parser.add_argument(
"-p",
"--http",
action="store",
default=7678,
help="Port on which to listen for did:keri resolution requests. Defaults to 7678",
)
parser.add_argument(
"-n",
"--name",
action="store",
default="dkr",
help="Name of controller. Default is dkr.",
)
parser.add_argument(
"--base",
"-b",
help="additional optional prefix to file location of KERI keystore",
required=False,
default="",
)
parser.add_argument(
"--passcode",
help="22 character encryption passcode for keystore (is not saved)",
dest="bran",
default=None,
) # passcode => bran
parser.add_argument(
"--config-dir",
"-c",
dest="configDir",
help="directory override for configuration data",
default=None,
)
parser.add_argument(
"--config-file",
dest="configFile",
action="store",
default=None,
help="configuration filename override",
)


def launch(args, expire=0.0):
Expand All @@ -46,22 +66,21 @@ def launch(args, expire=0.0):
configFile = args.configFile
configDir = args.configDir

ks = keeping.Keeper(name=name,
base=base,
temp=False,
reopen=True)
ks = keeping.Keeper(name=name, base=base, temp=False, reopen=True)

aeid = ks.gbls.get('aeid')
aeid = ks.gbls.get("aeid")

cf = None
if aeid is None:
if configFile is not None:
cf = configing.Configer(name=configFile,
base=base,
headDirPath=configDir,
temp=False,
reopen=True,
clear=False)
cf = configing.Configer(
name=configFile,
base=base,
headDirPath=configDir,
temp=False,
reopen=True,
clear=False,
)

hby = habbing.Habery(name=name, base=base, bran=bran, cf=cf)
else:
Expand Down
Loading

0 comments on commit ea53e90

Please sign in to comment.