From 7754a903139919d54cab1912197a4bf03a968410 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Wed, 18 Nov 2020 23:48:38 +0400 Subject: [PATCH] FileInfo is now a frozen dataclass for efficiency. --- scrapthechan/fileinfo.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/scrapthechan/fileinfo.py b/scrapthechan/fileinfo.py index 29e066e..039d9a8 100644 --- a/scrapthechan/fileinfo.py +++ b/scrapthechan/fileinfo.py @@ -1,23 +1,23 @@ -"""FileInfo object stores all needed information about a file.""" +"""FileInfo object stores information about a file.""" +from dataclasses import dataclass __all__ = ["FileInfo"] +@dataclass(frozen=True) class FileInfo: - """Stores all needed information about a file. + """Stores information about a file. - Arguments: - - `name` -- name of a file; - - `size` -- size of a file; - - `dlurl` -- full download URL for a file; - - `hash_value` -- hash sum of a file; - - `hash_algo` -- hash algorithm used (e.g. md5). - """ - def __init__(self, name: str, size: int, dlurl: str, - hash_value: str, hash_algo: str) -> None: - self.name = name - self.size = size - self.dlurl = dlurl - self.hash_value = hash_value - self.hash_algo = hash_algo + Fields: + - `name` -- name of a file; + - `size` -- size of a file; + - `download_url` -- full download URL for a file; + - `hash_value` -- hash sum of a file; + - `hash_algorithm` -- hash algorithm used (e.g. md5). + """ + name: str + size: int + download_url: str + hash_value: str + hash_algorithm: str