vcorelib.paths
index
/home/vkottler/src/vkottler/workspace/vcorelib/vcorelib/paths/__init__.py

Common path manipulation utilities.

 
Package Contents
       
base
context
find
hashing
info
info_cache

 
Functions
       
bytes_hash_hex(data: bytes, algorithm: str = 'sha256') -> str
Get the hex digest from some bytes for some provided hashing algorithm.
bytes_md5_hex(data: bytes) -> str
Get the MD5 sum for some bytes.
create_hex_digest(output: Union[pathlib.Path, str, NoneType], name: str, sources: Union[pathlib.Path, str, NoneType] = None, algorithm: str = 'sha256') -> pathlib.Path
Create a hex digest file based on file hashes in some directory.
file_hash_hex(path: Union[pathlib.Path, str, NoneType], algorithm: str = 'sha256') -> str
Get the hex digest from file data.
file_md5_hex(path: Union[pathlib.Path, str, NoneType]) -> str
Get an md5 hex string for a file by path.
find_file(path: Union[pathlib.Path, str, NoneType], *parts: Union[str, pathlib.Path], search_paths: Iterable[Union[pathlib.Path, str, NoneType]] = None, include_cwd: bool = False, relative_to: Union[pathlib.Path, str, NoneType] = None, package: str = None, package_subdir: str = 'data', logger: Union[logging.Logger, logging.LoggerAdapter[Any]] = None, strict: bool = False) -> Optional[pathlib.Path]
Combines a few simple strategies to locate a file on disk.
get_file_ext(path: Union[pathlib.Path, str, NoneType], maxsplit: int = -1) -> str
From a path to a file, get the file's extension. Use 'maxsplit' to control
how many suffixes are considered part of the name or the extension.
get_file_name(path: Union[pathlib.Path, str, NoneType], maxsplit: int = -1) -> str
From a path to a file, get the name of the file. Use 'maxsplit' to control
how many suffixes are considered part of the name or the extension.
modified_after(path: Union[pathlib.Path, str, NoneType], candidates: Iterable[Union[pathlib.Path, str, NoneType]]) -> bool
Check if any candidate paths are more recently modified than the provided
path. If the path doesn't exists but one or more of the candidates do, this
method returns True.
modified_ns(path: Union[pathlib.Path, str, NoneType]) -> Optional[int]
Get the last-modified time from a path if the data can be obtained.
normalize(path: Union[pathlib.Path, str, NoneType], *parts: Union[str, pathlib.Path], require: bool = False) -> pathlib.Path
Normalize an input that could be a path into a path.
rel(path: Union[pathlib.Path, str, NoneType], base: Union[pathlib.Path, str, NoneType] = None) -> pathlib.Path
Attempt to make 'path' relative to base (which is the current-working
directory, if not provided).
resource = find_file(path: Union[pathlib.Path, str, NoneType], *parts: Union[str, pathlib.Path], search_paths: Iterable[Union[pathlib.Path, str, NoneType]] = None, include_cwd: bool = False, relative_to: Union[pathlib.Path, str, NoneType] = None, package: str = None, package_subdir: str = 'data', logger: Union[logging.Logger, logging.LoggerAdapter[Any]] = None, strict: bool = False) -> Optional[pathlib.Path]
Combines a few simple strategies to locate a file on disk.
set_exec_flags(path: Union[pathlib.Path, str, NoneType]) -> None
Set the executable bits, but respect the 'read' bits.
stats(path: Union[pathlib.Path, str, NoneType]) -> Optional[os.stat_result]
Get stats for a file on disk if it exists.
str_hash_hex(data: str, encoding: str = 'utf-8', algorithm: str = 'sha256') -> str
Get the hex digest for string data.
str_md5_hex(data: str, encoding: str = 'utf-8') -> str
Get an md5 hex string from string data.
validate_hex_digest(path: Union[pathlib.Path, str, NoneType], root: Union[pathlib.Path, str, NoneType] = None, strict: bool = False) -> None
Attempt to validate a hex-digest file.

 
Data
        DEFAULT_HASH = 'sha256'
Pathlike = typing.Union[pathlib.Path, str, NoneType]
__all__ = ['Pathlike', 'normalize', 'stats', 'modified_ns', 'modified_after', 'get_file_name', 'get_file_ext', 'DEFAULT_HASH', 'bytes_hash_hex', 'str_hash_hex', 'file_hash_hex', 'bytes_md5_hex', 'str_md5_hex', 'file_md5_hex', 'set_exec_flags', 'rel', 'find_file', 'resource', 'create_hex_digest', 'validate_hex_digest']