From e45e9cb4080aa1908636fe113ad9786d63889aa1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 10 Oct 2021 01:27:34 +0200 Subject: [PATCH] loop --- package.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/package.py b/package.py index 2500fa9..2c43295 100644 --- a/package.py +++ b/package.py @@ -7,17 +7,13 @@ SEPARATOR = f'{os.linesep}{os.linesep}' class Package: def __init__(self, package, files): - p = package.decode(CHARSET).strip() - f = files.decode(CHARSET).strip() - text = f'{p}{SEPARATOR}{f}' - for item in text.split(SEPARATOR): - line, *lines = item.split(os.linesep) - key = line.split(KEY)[1].lower() - if len(lines) == 1: - value = lines[0] - else: - value = lines - setattr(self, key, value) - print() - print(key) - print(value) + for binary in [package, files]: + text = binary.decode(CHARSET).strip() + for item in text.split(SEPARATOR): + line, *lines = item.split(os.linesep) + key = line.split(KEY)[1].lower() + if len(lines) == 1: + value = lines[0] + else: + value = lines + setattr(self, key, value)