From 62ac569ec4ec4563681d4a6340bd60f15bb17387 Mon Sep 17 00:00:00 2001 From: I-Al-Istannen Date: Mon, 20 Apr 2020 16:59:08 +0200 Subject: [PATCH] Revert "Add proposed crawler entry type" This reverts commit 9f1a0a58aba19edac0bb220d986369adcd83579b. Each crawler will have its own data class. --- PFERD/types.py | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 PFERD/types.py diff --git a/PFERD/types.py b/PFERD/types.py deleted file mode 100644 index 3058260..0000000 --- a/PFERD/types.py +++ /dev/null @@ -1,46 +0,0 @@ -"""Contains common types.""" - -from pathlib import Path -from typing import Any, Dict, Union - - -class CrawlerEntry(): - """A single entry a crawler produced.""" - - def __init__(self, path: Path, url: str, extra_data: Dict[str, Any]): - """Create a new crawler entry. - - Arguments: - path {Path} -- the path of the entry the crawler built - url {str} -- the url to crawl it from - extra_data {Any} -- any extra data the crawler might produce - """ - self._path = path - self.url = url - self.extra_data = extra_data - - def __str__(self) -> str: - """Format the entry as a string.""" - return f"CrawlerEntry({self.path} - {self.url} - {self.extra_data})" - - @property - def path(self) -> Path: - """Return the path of this entry.""" - return self._path - - @property - def name(self) -> str: - """Return the name component of the path.""" - return self._path.name - - def rename(self, new_name: str) -> 'CrawlerEntry': - """Change the name (and nothing more) of the path.""" - return CrawlerEntry(Path(self._path.parent, new_name), self.url, self.extra_data) - - def move(self, new_path: Union[str, Path]) -> 'CrawlerEntry': - """Move the file to a different path.""" - return CrawlerEntry(self._to_path(new_path), self.url, self.extra_data) - - def _to_path(self, path: Union[str, Path]) -> Path: - """Convert a str/Path union to a Path.""" - return path if isinstance(path, Path) else Path(path)