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:
Kevin Morris 2021-11-17 08:04:33 -08:00
parent 3efb9a57b5
commit 29989b7fdb
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
7 changed files with 246 additions and 72 deletions

View file

@ -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()