mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-23 10:07:48 -06:00
fix: stop on one line when pyyaml is missing
This commit is contained in:
1 parent
eef13547e1
commit
7be8a7cd7b
7 files changed
+22
-30
No files matched your search
@@ -12,7 +12,6 @@ import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
import yaml
|
||||
from abc import ABC, abstractmethod
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
@@ -21,7 +20,12 @@ from typing import Any, Callable, NoReturn, Protocol, TypeVar
|
||||
from core.github import github_token
|
||||
from core.artifacts import copy_stream_atomic, write_text_atomic
|
||||
from core.upstream import forge_headers as upstream_headers
|
||||
from model.safeparse import yaml_load
|
||||
from model.safeparse import require_yaml, yaml_load
|
||||
|
||||
try:
|
||||
import yaml
|
||||
except ImportError:
|
||||
require_yaml() # exits with the install hint
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
import logging
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -37,9 +36,6 @@ def load_tracked_entries(
|
||||
|
||||
Returns {decoded_zip_name: (key, source_url)}.
|
||||
"""
|
||||
if importlib.util.find_spec("yaml") is None:
|
||||
print("Error: PyYAML required", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
with open(registry_path) as f:
|
||||
data = yaml_load(f) or {}
|
||||
entries: dict[str, tuple[str, str]] = {}
|
||||
|
||||
@@ -11,6 +11,7 @@ import pkgutil
|
||||
from abc import ABC, abstractmethod
|
||||
from pathlib import Path
|
||||
|
||||
from model.safeparse import require_yaml
|
||||
from model.sourcerevision import platform_revision
|
||||
|
||||
# Every target scraper reads the network through the platform scrapers'
|
||||
@@ -48,14 +49,10 @@ class BaseTargetScraper(ABC):
|
||||
|
||||
def write_output(self, data: dict, output_path: str) -> None:
|
||||
"""Write target data to YAML file."""
|
||||
try:
|
||||
import yaml
|
||||
except ImportError as exc:
|
||||
raise ImportError("PyYAML required: pip install pyyaml") from exc
|
||||
from core.artifacts import write_text_atomic
|
||||
|
||||
write_text_atomic(
|
||||
output_path, yaml.dump(data, default_flow_style=False, sort_keys=False)
|
||||
output_path, require_yaml().dump(data, default_flow_style=False, sort_keys=False)
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user