libs/apt some comments and clarifications
This commit is contained in:
parent
349b4e9d3f
commit
f075d4f3cd
1 changed files with 6 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
||||||
# https://manpages.debian.org/jessie/apt/sources.list.5.de.html
|
# https://manpages.debian.org/jessie/apt/sources.list.5.de.html
|
||||||
|
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from re import search, sub
|
from re import search, sub
|
||||||
from functools import total_ordering
|
from functools import total_ordering
|
||||||
|
@ -7,16 +8,20 @@ from functools import total_ordering
|
||||||
@total_ordering
|
@total_ordering
|
||||||
class AptSource():
|
class AptSource():
|
||||||
def __init__(self, string):
|
def __init__(self, string):
|
||||||
|
# parse options, which are optional
|
||||||
if search(r'\[.*\]', string):
|
if search(r'\[.*\]', string):
|
||||||
self.options = {
|
self.options = {
|
||||||
k:v.split(',') for k,v in (
|
k:v.split(',') for k,v in (
|
||||||
e.split('=') for e in search(r'\[(.*)\]', string)[1].split()
|
e.split('=') for e in search(r'\[(.*)\]', string)[1].split()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
string_without_options = sub(r'\[.*\]', '', string)
|
||||||
else:
|
else:
|
||||||
self.options = {}
|
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.type = parts[0]
|
||||||
self.url = urlparse(parts[1])
|
self.url = urlparse(parts[1])
|
||||||
self.suite = parts[2]
|
self.suite = parts[2]
|
||||||
|
|
Loading…
Reference in a new issue