From f075d4f3cd3e212c23b1c0d740019435a9df5f0f Mon Sep 17 00:00:00 2001 From: mwiegand Date: Thu, 3 Mar 2022 09:38:12 +0100 Subject: [PATCH] libs/apt some comments and clarifications --- libs/apt.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/apt.py b/libs/apt.py index 0798c41..74ede99 100644 --- a/libs/apt.py +++ b/libs/apt.py @@ -1,4 +1,5 @@ # https://manpages.debian.org/jessie/apt/sources.list.5.de.html + from urllib.parse import urlparse from re import search, sub from functools import total_ordering @@ -7,16 +8,20 @@ from functools import total_ordering @total_ordering class AptSource(): def __init__(self, string): + # parse options, which are optional if search(r'\[.*\]', string): self.options = { k:v.split(',') for k,v in ( e.split('=') for e in search(r'\[(.*)\]', string)[1].split() ) } + string_without_options = sub(r'\[.*\]', '', string) else: self.options = {} + string_without_options = string - parts = sub(r'\[.*\]', '', string).split() + # parse rest of source, now in defined order + parts = string_without_options.split() self.type = parts[0] self.url = urlparse(parts[1]) self.suite = parts[2]