Add export, temporary eth plugin inline
This commit is contained in:
parent
546a4d912a
commit
388c676d11
@ -1 +1 @@
|
||||
include requirements.txt
|
||||
include requirements.txt cic/data/* cic/schema/*
|
||||
|
@ -46,6 +46,12 @@ class Attachment(Data):
|
||||
os.makedirs(self.attachment_path)
|
||||
|
||||
|
||||
def get(self):
|
||||
def maphex(v):
|
||||
return v.hex()
|
||||
return list(map(maphex, self.digests))
|
||||
|
||||
|
||||
def __str__(self):
|
||||
s = ''
|
||||
for i in range(len(self.contents)):
|
||||
|
40
cic/cmd/export.py
Normal file
40
cic/cmd/export.py
Normal file
@ -0,0 +1,40 @@
|
||||
# standard imports
|
||||
import logging
|
||||
import importlib
|
||||
|
||||
# local imports
|
||||
from cic import Proof
|
||||
from cic.meta import Meta
|
||||
from cic.attachment import Attachment
|
||||
from cic.network import Network
|
||||
|
||||
logg = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def process_args(argparser):
|
||||
argparser.add_argument('-d', '--directory', type=str, dest='directory', default='.', help='directory')
|
||||
argparser.add_argument('-y', '--signer', type=str, dest='signer', help='target-specific signer to use for export')
|
||||
argparser.add_argument('target', type=str, help='target network type')
|
||||
|
||||
|
||||
def validate_args(args):
|
||||
pass
|
||||
|
||||
|
||||
def execute(config, eargs):
|
||||
modname = 'cic.ext.{}'.format(eargs.target)
|
||||
cmd_mod = importlib.import_module(modname)
|
||||
|
||||
cp = Proof(path=eargs.directory)
|
||||
cm = Meta(path=eargs.directory)
|
||||
ca = Attachment(path=eargs.directory)
|
||||
cn = Network(eargs.directory)
|
||||
|
||||
cp.load()
|
||||
cm.load()
|
||||
ca.load()
|
||||
cn.load()
|
||||
|
||||
ref = cn.reference(eargs.target)
|
||||
logg.debug('found reference {} for target {}'.format(ref, eargs.target))
|
||||
getattr(cmd_mod, 'new')(ref, ca.get())
|
@ -7,7 +7,6 @@ from cic import Proof
|
||||
from cic.meta import Meta
|
||||
from cic.attachment import Attachment
|
||||
from cic.network import Network
|
||||
|
||||
logg = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@ from cic.network import Network
|
||||
|
||||
def process_args(argparser):
|
||||
argparser.add_argument('-f', '--file', type=str, help='add file')
|
||||
argparser.add_argument('-d', '--directory', type=str, dest='directory', default='.', help='directory')
|
||||
argparser.add_argument('-d', '--directory', type=str, dest='directory', default='.', help='cic data directory')
|
||||
|
||||
|
||||
def validate_args(args):
|
||||
|
16
cic/ext/eth/__init__.py
Normal file
16
cic/ext/eth/__init__.py
Normal file
@ -0,0 +1,16 @@
|
||||
# standard imports
|
||||
import logging
|
||||
|
||||
logg = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CICEth:
|
||||
|
||||
def __init__(self, reference, proofs):
|
||||
self.reference = reference
|
||||
self.proofs = proofs
|
||||
logg.debug('eth strup with reference {} proofs {}'.format(reference, proofs))
|
||||
|
||||
|
||||
def new(reference, proofs):
|
||||
return CICEth(reference, proofs)
|
@ -35,6 +35,13 @@ class Network(Data):
|
||||
f.close()
|
||||
|
||||
|
||||
def reference(self, k):
|
||||
v = self.references.get(k)
|
||||
if v == None:
|
||||
raise AttributeError('no defined reference for {}'.format(k))
|
||||
return v
|
||||
|
||||
|
||||
def __str__(self):
|
||||
s = ''
|
||||
for k in self.references.keys():
|
||||
|
@ -47,6 +47,7 @@ class Proof(Data):
|
||||
f.close()
|
||||
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return """description: {}
|
||||
""".format(self.description)
|
||||
|
@ -8,6 +8,7 @@ import importlib
|
||||
# external imports
|
||||
import cic.cmd.init as cmd_init
|
||||
import cic.cmd.show as cmd_show
|
||||
import cic.cmd.export as cmd_export
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
@ -26,6 +27,8 @@ sub_init = sub.add_parser('init', help='initialize new cic data directory')
|
||||
cmd_init.process_args(sub_init)
|
||||
sub_show = sub.add_parser('show', help='display summary of current state of cic data directory')
|
||||
cmd_show.process_args(sub_show)
|
||||
sub_export = sub.add_parser('export', help='export cic data directory state to a specified target')
|
||||
cmd_export.process_args(sub_export)
|
||||
|
||||
args = argparser.parse_args(sys.argv[1:])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user