Split out Contents file reading.
This commit is contained in:
parent
456b47bb97
commit
05bad21f1f
1 changed files with 10 additions and 5 deletions
|
@ -111,6 +111,14 @@ class ContentsFileNotFound(Exception):
|
|||
"""The contents file was not found."""
|
||||
|
||||
|
||||
def read_contents_file(f):
|
||||
for line in f:
|
||||
(path, rest) = line.rsplit(maxsplit=1)
|
||||
package = rest.split(b"/")[-1]
|
||||
decoded_path = "/" + path.decode("utf-8", "surrogateescape")
|
||||
yield decoded_path, package.decode("utf-8")
|
||||
|
||||
|
||||
class AptContentsFileSearcher(FileSearcher):
|
||||
def __init__(self):
|
||||
self._db = {}
|
||||
|
@ -145,11 +153,8 @@ class AptContentsFileSearcher(FileSearcher):
|
|||
yield pkg
|
||||
|
||||
def load_file(self, f):
|
||||
for line in f:
|
||||
(path, rest) = line.rsplit(maxsplit=1)
|
||||
package = rest.split(b"/")[-1]
|
||||
decoded_path = "/" + path.decode("utf-8", "surrogateescape")
|
||||
self[decoded_path] = package.decode("utf-8")
|
||||
for path, package in read_contents_file(f):
|
||||
self[path] = package
|
||||
|
||||
@classmethod
|
||||
def _load_cache_file(cls, url, cache_dir):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue