feat: add interactive deployment and switch to poetry #2
@ -134,7 +134,7 @@ class Network(Data):
|
||||
for resource in self.resources.keys():
|
||||
for content_key in self.resources[resource]['contents'].keys():
|
||||
content_value = self.resources[resource]['contents'][content_key]
|
||||
if content_value == None:
|
||||
if content_value is None:
|
||||
content_value = ''
|
||||
s += f'{resource}.{content_key} = {content_value}\n'
|
||||
|
||||
|
@ -4,10 +4,9 @@ import logging
|
||||
import os
|
||||
import sys
|
||||
import urllib.request
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from cic_types.ext.metadata import MetadataRequestsHandler
|
||||
import json
|
||||
|
||||
from cic_types.ext.metadata import MetadataRequestsHandler, MetadataPointer
|
||||
|
||||
logg = logging.getLogger(__name__)
|
||||
|
||||
@ -22,7 +21,7 @@ class OutputWriter:
|
||||
|
||||
class StdoutWriter(OutputWriter):
|
||||
def write(self, k, v):
|
||||
sys.stdout.write("{}\t{}\n".format(k, v))
|
||||
sys.stdout.write(f"{k}\t{v}\n")
|
||||
|
||||
|
||||
class KVWriter(OutputWriter):
|
||||
@ -35,7 +34,7 @@ class KVWriter(OutputWriter):
|
||||
|
||||
def write(self, k, v):
|
||||
fp = os.path.join(self.path, str(k))
|
||||
logg.debug("path write {} {}".format(fp, str(v)))
|
||||
logg.debug(f"path write {fp} {str(v)}")
|
||||
f = open(fp, "wb")
|
||||
f.write(v)
|
||||
f.close()
|
||||
@ -48,12 +47,12 @@ class HTTPWriter(OutputWriter):
|
||||
|
||||
def write(self, k, v):
|
||||
path = self.path
|
||||
if k != None:
|
||||
if k is not None:
|
||||
path = os.path.join(path, k)
|
||||
logg.debug(f"http writer post {path} \n key: {k}, value: {v}")
|
||||
rq = urllib.request.Request(path, method="POST", data=v)
|
||||
r = urllib.request.urlopen(rq)
|
||||
logg.info("http writer submitted at {}".format(r.read()))
|
||||
logg.info(f"http writer submitted at {r.read()}")
|
||||
|
||||
|
||||
class KeyedWriter(OutputWriter):
|
||||
@ -61,14 +60,14 @@ class KeyedWriter(OutputWriter):
|
||||
self.writer_keyed = writer_keyed
|
||||
self.writer_immutable = writer_immutable
|
||||
|
||||
def write(self, key, value):
|
||||
logg.debug(f"writing keywriter key: {key} value: {value}")
|
||||
def write(self, k, v):
|
||||
logg.debug(f"writing keywriter key: {k} value: {v}")
|
||||
if isinstance(value, str):
|
||||
value = value.encode("utf-8")
|
||||
if self.writer_keyed != None:
|
||||
self.writer_keyed.write(key, value)
|
||||
if self.writer_immutable != None:
|
||||
self.writer_immutable.write(None, value)
|
||||
if self.writer_keyed is not None:
|
||||
self.writer_keyed.write(k, v)
|
||||
if self.writer_immutable is not None:
|
||||
self.writer_immutable.write(None, v)
|
||||
|
||||
|
||||
class KeyedWriterFactory:
|
||||
@ -78,16 +77,16 @@ class KeyedWriterFactory:
|
||||
self.key_writer_constructor = key_writer_constructor
|
||||
self.immutable_writer_constructor = immutable_writer_constructor
|
||||
self.x = {}
|
||||
for k in kwargs.keys():
|
||||
logg.debug("adding key {} t keyed writer factory".format(k))
|
||||
self.x[k] = kwargs[k]
|
||||
for k, v in kwargs.items():
|
||||
logg.debug(f"adding key {k} t keyed writer factory")
|
||||
self.x[k] = v
|
||||
|
||||
def new(self, path=None, *args, **kwargs):
|
||||
writer_keyed = None
|
||||
writer_immutable = None
|
||||
if self.key_writer_constructor != None:
|
||||
if self.key_writer_constructor is not None:
|
||||
writer_keyed = self.key_writer_constructor(path, **self.x)
|
||||
if self.immutable_writer_constructor != None:
|
||||
if self.immutable_writer_constructor is not None:
|
||||
writer_immutable = self.immutable_writer_constructor(path, **self.x)
|
||||
return KeyedWriter(writer_keyed, writer_immutable)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user