Skip to content
Open
29 changes: 29 additions & 0 deletions BlocksScreen/helper_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,32 @@ def check_file_on_path(
"""Check if file exists on path. Returns true if file exists on that specified directory"""
_filepath = os.path.join(path, filename)
return os.path.exists(_filepath)


def get_file_loc(filename) -> pathlib.Path: ...


def get_file_name(filename: typing.Optional[str]) -> str:
# If filename is None or empty, return empty string instead of None
if not filename:
return ""
# Remove trailing slashes or backslashes
filename = filename.rstrip("/\\")

# Normalize Windows backslashes to forward slashes
filename = filename.replace("\\", "/")

parts = filename.split("/")

# Split and return the last path component
return parts[-1] if filename else ""


# def get_hash(data) -> hashlib._Hash:
# hash = hashlib.sha256()
# hash.update(data.encode())
# hash.digest()
# return hash


def digest_hash() -> None: ...
Loading
Loading