diff --git a/deploy.ps1 b/deploy.ps1 new file mode 100644 index 0000000..38bfb8d --- /dev/null +++ b/deploy.ps1 @@ -0,0 +1,13 @@ +$ErrorActionPreference = "Stop" + +$VERSION = $(python -c 'import hypy_utils; print(hypy_utils.__version__)') +Write-Output "$VERSION" + +# Build +python setup.py sdist bdist_wheel + +# Check +python -m twine check dist/* + +# Upload +python -m twine upload dist/* diff --git a/hypy_utils/__init__.py b/hypy_utils/__init__.py index 11ecbb1..1100c7c 100644 --- a/hypy_utils/__init__.py +++ b/hypy_utils/__init__.py @@ -1,6 +1,7 @@ -__version__ = "1.0.1" +__version__ = "1.0.2" import dataclasses +import hashlib import json from datetime import datetime, date from pathlib import Path @@ -157,3 +158,18 @@ def read(file: Union[str, Path]) -> str: :return: None """ return file.read_text('utf-8') + + +def md5(file: Union[str, Path]) -> str: + """ + Compute md5 of a file + + :param file: File path + :return: md5 string + """ + file = Path(file) + hash_md5 = hashlib.md5() + with open(file, "rb") as f: + for chunk in iter(lambda: f.read(4096), b""): + hash_md5.update(chunk) + return hash_md5.hexdigest()