aboutsummaryrefslogtreecommitdiff
path: root/src/wikiget/validations.py
diff options
context:
space:
mode:
authorCody Logan <cody@lokken.dev>2023-12-01 15:33:21 -0800
committerCody Logan <cody@lokken.dev>2023-12-01 15:33:21 -0800
commit318d9ad1a4679832b380c77ab1a0a86684f686f2 (patch)
treeee1bd8ad347c18b3fc44da388360634c3afd231c /src/wikiget/validations.py
parent488e859f8c343b0ef25db379b6339bf82769514b (diff)
downloadwikiget-318d9ad1a4679832b380c77ab1a0a86684f686f2.tar.gz
wikiget-318d9ad1a4679832b380c77ab1a0a86684f686f2.zip
Switch to Google-style docstrings for readability
The previous Sphinx-style docstrings could be hard to read at a glance when formatted with pydoc.
Diffstat (limited to 'src/wikiget/validations.py')
-rw-r--r--src/wikiget/validations.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/wikiget/validations.py b/src/wikiget/validations.py
index bde39df..b4bbeba 100644
--- a/src/wikiget/validations.py
+++ b/src/wikiget/validations.py
@@ -36,10 +36,11 @@ def valid_file(search_string: str) -> re.Match | None:
file prefixes in MediaWiki), includes a period, and has at least one character
following the period, like 'File:Example.jpg' or 'Image:Example.svg'.
- :param search_string: string to validate
- :type search_string: str
- :returns: a regex Match object if there's a match or None otherwise
- :rtype: re.Match
+ Args:
+ search_string (str): string to validate
+
+ Returns:
+ re.Match: a regex Match object if there's a match or None otherwise
"""
# second group could also restrict to file extensions with three or more
# letters with ([^/\r\n\t\f\v]+\.\w{3,})
@@ -56,10 +57,11 @@ def valid_site(search_string: str) -> re.Match | None:
Currently unused since any site is accepted as input, and we rely on the user to
ensure the site has a compatible API.
- :param search_string: string to validate
- :type search_string: str
- :returns: a regex Match object if there's a match or None otherwise
- :rtype: re.Match
+ Args:
+ search_string (str): string to validate
+
+ Returns:
+ re.Match: a regex Match object if there's a match or None otherwise
"""
site_regex = re.compile(r"wiki[mp]edia\.org$", re.I)
return site_regex.search(search_string)
@@ -71,10 +73,11 @@ def verify_hash(file: Path) -> str:
Despite being insecure, SHA1 is used since that's what the MediaWiki API returns for
the file hash.
- :param filename: name of the file to calculate a hash for
- :type filename: str
- :return: hash digest
- :rtype: str
+ Args:
+ file (pathlib.Path): file to calculate a hash for, as a Path object
+
+ Returns:
+ str: hash digest
"""
hasher = hashlib.sha1() # noqa: S324
with file.open("rb") as dl: