System Management Functions
System management utilities.
- system_management_functions.system_management_functions.convert_blob_to_raw_github_url(blob_url: str) str[source]
Converts a GitHub “blob” URL to a “raw” content URL.
- GitHub blob URL:
https://github.com/{user}/{repo}/blob/{branch}/{path}
- Converted raw URL:
https://github.com/{user}/{repo}/raw/{branch}/{path}
- Parameters:
blob_url (str) – The GitHub blob URL to convert.
- Returns:
The converted raw GitHub URL.
- Return type:
str
- Raises:
ValueError – If the input URL does not contain “/blob/”.
- system_management_functions.system_management_functions.get_file_size(path: str | Path) int[source]
Returns the size in bytes of a file or directory. Accepts either a string path or a Path object.
- system_management_functions.system_management_functions.get_file_size_human_readable(path: str | Path) str[source]
Returns the size of the file or directory in a human-readable format. Supports units: bytes, KB, MB, GB, TB (3 decimal places). Accepts str or Path input.
- system_management_functions.system_management_functions.valid_Windows_filename(name: str | Path) bool[source]
Checks whether a given filename is valid according to Windows naming rules.
This function is a simplified wrapper around validate_Windows_filename_with_reasons that returns only a boolean indicating validity.
- Parameters:
name (str or Path) – The filename to check.
- Returns:
True if the filename is valid, False otherwise.
- Return type:
bool
- system_management_functions.system_management_functions.validate_Windows_filename_with_reasons(name: str | Path) dict[source]
Validates a Windows filename against Microsoft’s file naming restrictions.
This function uses a JSON ruleset hosted on GitHub that defines: - Disallowed characters grouped by category - Reserved device names (e.g., CON, NUL, COM1) - Forbidden trailing characters (space or period)
The JSON rules are retrieved via HTTP with up to 100 retries using the requests library.
- Parameters:
name (str or Path) – The filename to validate (e.g., “nul.txt”).
- Returns:
- A dictionary indicating whether the filename is valid.
- If valid:
- {
“valid”: True
}
- If invalid:
- {
“valid”: False, “problems”: [
- {
“character”: “<offending character or name>”, “reason”: “<explanation of the problem>”
]
}
- Return type:
dict
- Raises:
RuntimeError – If the rules file cannot be retrieved after 100 attempts.
ValueError – If the GitHub blob URL is malformed.