pylibswarm

Python3 wrapper for libswarm-ng
git clone git://git.defalsify.org/pylibswarm.git
Log | Files | Refs | Submodules | README | LICENSE

commit d7066f4184e88bbf83e035931bde371244cb9ddc
parent 4ff6099dfb27b8772896e84214036eec2d2318d4
Author: nolash <dev@holbrook.no>
Date:   Fri,  1 Oct 2021 15:31:03 +0200

Remove input requirement when generating soc id

Diffstat:
MREADME | 9+++++++++
Mswarm/runnable/soc.py | 47++++++++++++++++++++++++-----------------------
2 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/README b/README @@ -27,3 +27,12 @@ $ python pylibswarm/runnable/file.py -vv -o chunkdir LICENSE # other options $ python pylibswarm/runnable/file.py --help + +# create an soc chunk +$ python pylibswarm/runnable/soc.py --topic-string foo --index-string bar baz + +# create and output an soc chunk +$ python pylibswarm/runnable/soc.py --topic-string foo --index-string bar -o outdir baz + +# generate soc identifier +$ python pylibswarm/runnable/soc.py --topic-string foo --index-string bar --id diff --git a/swarm/runnable/soc.py b/swarm/runnable/soc.py @@ -47,33 +47,34 @@ elif largs.v: filepath = None input_data = None -if largs.f: - filepath = os.path.realpath(largs.f) - f = open(filepath, 'rb') - data = f.read() - f.close() - logg.info('data read from file: {}'.format(filepath)) -else: - data = largs.data - if data == None: - data = stdin_arg() - logg.info('data read from positional argument'.format(filepath)) +if largs.id == None: + if largs.f: + filepath = os.path.realpath(largs.f) + f = open(filepath, 'rb') + data = f.read() + f.close() + logg.info('data read from file: {}'.format(filepath)) else: - logg.info('data read from stdin'.format(filepath)) + data = largs.data + if data == None: + data = stdin_arg() + logg.info('data read from positional argument'.format(filepath)) + else: + logg.info('data read from stdin'.format(filepath)) -input_data = data -if not largs.u: - input_data.rstrip() - if isinstance(input_data, str): - input_data = data.encode('utf-8') + input_data = data + if not largs.u: + input_data.rstrip() + if isinstance(input_data, str): + input_data = data.encode('utf-8') -input_data_length = len(input_data) -data_length = input_data_length -if largs.data_length != None: - data_length = largs.data_length -logg.debug('input length {}'.format(input_data_length)) -logg.debug('span length {}'.format(data_length)) + input_data_length = len(input_data) + data_length = input_data_length + if largs.data_length != None: + data_length = largs.data_length + logg.debug('input length {}'.format(input_data_length)) + logg.debug('span length {}'.format(data_length)) src_topic = None src_index = None