From e2008e87003a972eb7614989528e05d7dc307a35 Mon Sep 17 00:00:00 2001 From: coderkun Date: Sun, 17 May 2020 11:34:44 +0200 Subject: [PATCH] Make all package fields optional --- arch.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/arch.py b/arch.py index a1383d8..0de3820 100644 --- a/arch.py +++ b/arch.py @@ -44,17 +44,28 @@ class ArchDatabase: s = df.read().decode('utf-8') d = dict(item.split("\n")[:2] for item in s.split("\n\n")[:-1]) - archPackage = ArchPackage(d["%NAME%"]) - archPackage.set_filename(d["%FILENAME%"]) - archPackage.set_version(d["%VERSION%"]) - archPackage.set_desc(d["%DESC%"]) - archPackage.set_csize(d["%CSIZE%"]) - archPackage.set_isize(d["%ISIZE%"]) - archPackage.set_url(d["%URL%"]) - archPackage.set_license(d["%LICENSE%"]) - archPackage.set_arch(d["%ARCH%"]) - archPackage.set_builddate(d["%BUILDDATE%"]) - archPackage.set_packager(d["%PACKAGER%"]) + if "%NAME%" in d: + archPackage = ArchPackage(d["%NAME%"]) + if "%FILENAME%" in d: + archPackage.set_filename(d["%FILENAME%"]) + if "%VERSION%" in d: + archPackage.set_version(d["%VERSION%"]) + if "%DESC%" in d: + archPackage.set_desc(d["%DESC%"]) + if "%CSIZE%" in d: + archPackage.set_csize(d["%CSIZE%"]) + if "%ISIZE%" in d: + archPackage.set_isize(d["%ISIZE%"]) + if "%URL%" in d: + archPackage.set_url(d["%URL%"]) + if "%LICENSE%" in d: + archPackage.set_license(d["%LICENSE%"]) + if "%ARCH%" in d: + archPackage.set_arch(d["%ARCH%"]) + if "%BUILDDATE%" in d: + archPackage.set_builddate(d["%BUILDDATE%"]) + if "%PACKAGER%" in d: + archPackage.set_packager(d["%PACKAGER%"]) self.packages.append(archPackage)