mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-06-12 18:15:30 -05:00
refactor: deduplicate yaml import pattern via require_yaml()
This commit is contained in:
@@ -21,6 +21,17 @@ except ImportError:
|
||||
yaml = None
|
||||
|
||||
|
||||
def require_yaml():
|
||||
"""Import and return yaml, exiting if PyYAML is not installed."""
|
||||
try:
|
||||
import yaml as _yaml
|
||||
return _yaml
|
||||
except ImportError:
|
||||
import sys
|
||||
print("Error: PyYAML required (pip install pyyaml)", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def compute_hashes(filepath: str | Path) -> dict[str, str]:
|
||||
"""Compute SHA1, MD5, SHA256, CRC32, Adler32 for a file."""
|
||||
sha1 = hashlib.sha1()
|
||||
|
||||
Reference in New Issue
Block a user