Add HttpCrawler

This commit is contained in:
Joscha
2021-05-13 22:28:14 +02:00
parent 961f40f9a1
commit d565df27b3
4 changed files with 51 additions and 5 deletions

View File

@ -44,12 +44,16 @@ class Report:
"""
def __init__(self) -> None:
self.reserved_files: Set[PurePath] = set()
self.known_files: Set[PurePath] = set()
self.new_files: Set[PurePath] = set()
self.changed_files: Set[PurePath] = set()
self.deleted_files: Set[PurePath] = set()
def mark_reserved(self, path: PurePath) -> None:
self.reserved_files.add(path)
def mark(self, path: PurePath) -> None:
"""
Mark a previously unknown file as known.
@ -58,12 +62,12 @@ class Report:
detail, see the respective exception's docstring.
"""
for known_path in self.known_files:
if path == known_path:
for other in self.known_files & self.reserved_files:
if path == other:
raise MarkDuplicateException(path)
if is_relative_to(path, known_path) or is_relative_to(known_path, path):
raise MarkConflictException(path, known_path)
if is_relative_to(path, other) or is_relative_to(other, path):
raise MarkConflictException(path, other)
self.known_files.add(path)