7. utils

Module providing miscellaneous utilities used by cmkinitramfs

cmkinitramfs.utils.removeprefix(string, prefix)[source]

Remove a prefix from a string

Add support for str.removeprefix() for Python < 3.9.

Parameters
  • string (str) – String to remove prefix from

  • prefix (str) – Prefix to remove

Return type

str

cmkinitramfs.utils.normpath(path)[source]

Normalize path (actually eliminates double slashes)

Parameters

path (str) – Path to normalize

Return type

str

cmkinitramfs.utils.hash_file(filepath, chunk_size=65536)[source]

Calculate the SHA512 of a file

Parameters
  • filepath (str) – Path of the file to hash

  • chunk_size (int) – Number of bytes per chunk of file to hash

Returns

File hash in a bytes object

Return type

bytes