partsdb

electronic parts inventory
git clone https://git.e1e0.net/partsdb.git
Log | Files | Refs

commit 604a8365c76e259cd68fb7ba76ec4cb86f0cfcfd
parent 433446338c9ffbfd25be6724256b47327eaa56f4
Author: Paco Esteban <paco@e1e0.net>
Date:   Mon, 15 Mar 2021 18:38:58 +0100

visual decoration of list

Diffstat:
Mhelpers.py | 16++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/helpers.py b/helpers.py @@ -7,23 +7,21 @@ import tempfile def print_parts_list(parts, short=False): if short: - header = (f"{'ID':4} | " + header = (f"| {'ID':4} | " f"{'Category':8} | " f"{'PN':10} | " - f"{'Manufacturer':18} | " + f"{'Manufacturer':16} | " f"{'Description':25} |" ) - print(header) - print("-"*79) for i, p in enumerate(parts): if i % 25 == 0: print("-"*79) print(header) print("-"*79) - print(f"{p['id']:<4} | " + print(f"| {p['id']:<4} | " f"{p['cname'][0:7]:8} | " f"{_sanitize_value(p['pn'])[0:9]:10} | " - f"{_sanitize_value(p['manufacturer'])[0:17]:18} | " + f"{_sanitize_value(p['manufacturer'])[0:15]:16} | " f"{_sanitize_value(p['description'])[0:24]:25} |" ) else: @@ -42,7 +40,7 @@ def print_parts_list(parts, short=False): l_man = l_man if l_man > len('Manufacturer') else len('Manufacturer') l_desc = l_desc if l_desc > len('Description') else len('Description') - header = (f"{'ID':5} | {'PN':{l_pn}} | " + header = (f"| {'ID':5} | {'PN':{l_pn}} | " f"{'Category':{l_cat}} | " f"{'Manufacturer':{l_man}} | " f"{'Description':{l_desc}} | " @@ -50,14 +48,12 @@ def print_parts_list(parts, short=False): f"{'Footp':6} | " f"{'Qty':4} |" ) - print(header) - print("-"*len(header)) for i, p in enumerate(parts): if i % 25 == 0: print("-"*len(header)) print(header) print("-"*len(header)) - print(f"{p['id']:<5} | {p['pn']:{l_pn}} | " + print(f"| {p['id']:<5} | {p['pn']:{l_pn}} | " f"{p['cname']:{l_cat}} | " f"{_sanitize_value(p['manufacturer']):{l_man}} | " f"{_sanitize_value(p['description']):{l_desc}} | "