aboutsummaryrefslogtreecommitdiff
path: root/src/wikiget/validations.py
diff options
context:
space:
mode:
authorCody Logan <cody@lokken.dev>2023-11-08 12:00:45 -0800
committerCody Logan <cody@lokken.dev>2023-11-08 12:00:45 -0800
commitecaa8a2d019cef5a83a8dc0ed1d4ad5c9fc81a72 (patch)
tree571b803162477b01ff4df5776cfe7972cc216c40 /src/wikiget/validations.py
parente8da17d8c6b7fd879e196ae425b8e62c78e579fe (diff)
downloadwikiget-ecaa8a2d019cef5a83a8dc0ed1d4ad5c9fc81a72.tar.gz
wikiget-ecaa8a2d019cef5a83a8dc0ed1d4ad5c9fc81a72.zip
Add and refine docstrings in tests folder.
Diffstat (limited to 'src/wikiget/validations.py')
-rw-r--r--src/wikiget/validations.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/wikiget/validations.py b/src/wikiget/validations.py
index ee73b87..18c1f86 100644
--- a/src/wikiget/validations.py
+++ b/src/wikiget/validations.py
@@ -25,10 +25,11 @@ from wikiget import BLOCKSIZE
def valid_file(search_string: str) -> re.Match | None:
- """
- Determines if the given string contains a valid file name, defined as a string
- ending with a '.' and at least one character, beginning with 'File:' or 'Image:',
- the standard file prefixes in MediaWiki.
+ """Determines if the given string contains a valid file name
+
+ A valid file name is a string that begins with 'File:' or 'Image:' (the standard
+ 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
@@ -42,10 +43,10 @@ def valid_file(search_string: str) -> re.Match | None:
def valid_site(search_string: str) -> re.Match | None:
- """
- Determines if the given string contains a valid site name, defined as a string
- ending with 'wikipedia.org' or 'wikimedia.org'. This covers all subdomains of those
- domains.
+ """Determines if the given string contains a valid site name
+
+ A valid site name is a string ending with 'wikipedia.org' or 'wikimedia.org'. This
+ covers all subdomains of those domains.
Currently unused since any site is accepted as input, and we rely on the user to
ensure the site has a compatible API.
@@ -60,8 +61,10 @@ def valid_site(search_string: str) -> re.Match | None:
def verify_hash(filename: str) -> str:
- """
- Calculates the SHA1 hash of the given file for comparison with a known value.
+ """Calculates the SHA1 hash of the given file for comparison with a known value.
+
+ 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