From 1364d66264483d9cd1208df3ff5271a32be5fd54 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Fri, 23 Oct 2020 07:47:10 -0700 Subject: [PATCH] Let kbps return all three values always. Instead of just the missing value. --- voussoirkit/kbps.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/voussoirkit/kbps.py b/voussoirkit/kbps.py index 16caa4f..47f14ab 100644 --- a/voussoirkit/kbps.py +++ b/voussoirkit/kbps.py @@ -20,33 +20,27 @@ def kbps(time=None, size=None, kbps=None): if time is None: kilobits = size / 128 time = kilobits / kbps - return time if size is None: kibs = kbps / 8 size = kibs * 1024 size *= time - return size if kbps is None: kibs = size / 1024 kilobits = kibs * 8 kbps = kilobits / time - return kbps + + return (time, size, kbps) def kbps_argparse(args): time = args.time and hms.hms_to_seconds(args.time) size = args.size and bytestring.parsebytes(args.size) kibs = args.kbps and int(args.kbps) - result = kbps(time=time, size=size, kbps=kibs) + (time, size, kibs) = kbps(time=time, size=size, kbps=kibs) - if time is None: - print(hms.seconds_to_hms(time)) - if size is None: - print(bytestring.bytestring(size)) - if kibs is None: - print('%d kbps' % round(result)) + print(f'{hms.seconds_to_hms(time)} @ {kibs} kbps = {bytestring.bytestring(size)}') def main(argv): parser = argparse.ArgumentParser()