mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
change(aurblup): converted to use aurweb.db ORM
Introduces: - aurweb.testing.alpm.AlpmDatabase - Used to mock up and manage a remote repository. - templates/testing/alpm_package.j2 - Used to generate a single ALPM package desc. - Removed aurblup sharness test Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
3efb9a57b5
commit
29989b7fdb
7 changed files with 246 additions and 72 deletions
|
@ -176,3 +176,20 @@ def strtobool(value: str) -> bool:
|
|||
if isinstance(value, str):
|
||||
return _strtobool(value)
|
||||
return value
|
||||
|
||||
|
||||
def file_hash(filepath: str, hash_function: Callable) -> str:
|
||||
"""
|
||||
Return a hash of filepath contents using `hash_function`.
|
||||
|
||||
`hash_function` can be any one of the hashlib module's hash
|
||||
functions which implement the `hexdigest()` method -- e.g.
|
||||
hashlib.sha1, hashlib.md5, etc.
|
||||
|
||||
:param filepath: Path to file you want to hash
|
||||
:param hash_function: hashlib hash function
|
||||
:return: hash_function(filepath_content).hexdigest()
|
||||
"""
|
||||
with open(filepath, "rb") as f:
|
||||
hash_ = hash_function(f.read())
|
||||
return hash_.hexdigest()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue