From 855041aee928b50001c7efdc1a3953357eea245e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelmer=20Vernoo=C4=B3?= Date: Wed, 24 Mar 2021 00:21:11 +0000 Subject: [PATCH] Support loading from file. --- ognibuild/debian/file_search.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ognibuild/debian/file_search.py b/ognibuild/debian/file_search.py index cba1c26..dda9dc6 100644 --- a/ognibuild/debian/file_search.py +++ b/ognibuild/debian/file_search.py @@ -244,6 +244,18 @@ class GeneratedFileSearcher(FileSearcher): def __init__(self, db): self._db = db + @classmethod + def from_path(cls, path): + self = cls({}) + self.load_from_path(path) + return self + + def load_from_path(self, path): + with open(path, 'r') as f: + for line in f: + (path, pkg) = line.strip().split(None, 1) + self._db[path] = pkg + def search_files(self, path: str, regex: bool = False) -> Iterator[str]: for p, pkg in sorted(self._db.items()): if regex: