mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
refactor: move upstream, sourceref, version_basis
upstream reads forges with the standard library alone and scrapers, packs and the site read it: it goes to core. sourceref is the grammar of a profile field, which the site parses without the comparison tool: it goes to model. version_basis is read by profile_sync alone and opens the profiling package.
This commit is contained in:
1 parent
8cdda10393
commit
e1f2f8685d
29 files changed
+51
-49
No files matched your search
@@ -14,6 +14,7 @@ on:
|
||||
- "scripts/archive_build.py"
|
||||
- "scripts/auto_fetch.py"
|
||||
- "scripts/build_port.py"
|
||||
- "scripts/core/__init__.py"
|
||||
- "scripts/core/artifacts.py"
|
||||
- "scripts/core/cli.py"
|
||||
- "scripts/core/crypto_verify.py"
|
||||
@@ -24,6 +25,7 @@ on:
|
||||
- "scripts/core/romdir.py"
|
||||
- "scripts/core/sect233r1.py"
|
||||
- "scripts/core/torrentzip.py"
|
||||
- "scripts/core/upstream.py"
|
||||
- "scripts/core/ziptools.py"
|
||||
- "scripts/cross_reference.py"
|
||||
- "scripts/dedup.py"
|
||||
@@ -49,6 +51,7 @@ on:
|
||||
- "scripts/model/registry.py"
|
||||
- "scripts/model/retired.py"
|
||||
- "scripts/model/safeparse.py"
|
||||
- "scripts/model/sourceref.py"
|
||||
- "scripts/model/sources.py"
|
||||
- "scripts/model/systems.py"
|
||||
- "scripts/model/targets.py"
|
||||
@@ -104,9 +107,7 @@ on:
|
||||
- "scripts/sitewanted.py"
|
||||
- "scripts/sitewrite.py"
|
||||
- "scripts/slots.py"
|
||||
- "scripts/sourceref.py"
|
||||
- "scripts/split_pack.py"
|
||||
- "scripts/upstream.py"
|
||||
- "scripts/validate_pr.py"
|
||||
- "scripts/validate_schemas.py"
|
||||
- "scripts/validate_site.py"
|
||||
|
||||
@@ -52,7 +52,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
import export_native
|
||||
import pin_installer
|
||||
import refresh_data_dirs
|
||||
import upstream
|
||||
from core import upstream
|
||||
from core.cli import InputMissing, require_directory, suggest_names
|
||||
from model.targets import apply_target_overrides
|
||||
from model.registry import list_registered_platforms, load_platform_registry
|
||||
|
||||
File renamed without changes.
@@ -24,7 +24,7 @@ from pathlib import Path
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
|
||||
import upstream
|
||||
from core import upstream
|
||||
from core.cli import require_directory, suggest_names
|
||||
from profile_sync import collect_citations, ref_role, select_views, split_source_ref
|
||||
from model.safeparse import yaml_load
|
||||
|
||||
@@ -21,7 +21,7 @@ import urllib.parse
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
import upstream
|
||||
from core import upstream
|
||||
|
||||
# Commits listed per page and the most pages walked: a data file older than
|
||||
# 2 000 commits on its own path is not one a platform list still pins.
|
||||
|
||||
@@ -26,7 +26,7 @@ from dataclasses import dataclass
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
|
||||
import upstream
|
||||
from core import upstream
|
||||
from core.cli import require_directory
|
||||
from model.safeparse import yaml_load
|
||||
from scraper.mame_parser import _MACHINE_MACROS, strip_comments
|
||||
|
||||
File renamed without changes.
@@ -32,8 +32,8 @@ import yaml
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
|
||||
import upstream
|
||||
import version_basis
|
||||
from core import upstream
|
||||
from profiling import version_basis
|
||||
from model.systems import _norm_system_id, system_index
|
||||
from core.github import github_token
|
||||
from model.registry import list_registered_platforms
|
||||
@@ -42,7 +42,7 @@ from model.platforms import load_platform_config
|
||||
from resolve.cores import resolve_platform_cores
|
||||
from core.cli import suggest_names
|
||||
from core.hashing import parse_hash_list
|
||||
from sourceref import ( # re-exported for callers and tests
|
||||
from model.sourceref import (
|
||||
_ANNOTATION_RE as _ANNOTATION_RE,
|
||||
_BARE_RANGE_RE as _BARE_RANGE_RE,
|
||||
_LOCATED_RE as _LOCATED_RE,
|
||||
@@ -73,7 +73,7 @@ from sourceref import ( # re-exported for callers and tests
|
||||
split_outside_parentheses as split_outside_parentheses,
|
||||
split_source_ref as split_source_ref,
|
||||
)
|
||||
from upstream import CompareResult, find_renamed
|
||||
from core.upstream import CompareResult, find_renamed
|
||||
|
||||
DEFAULT_CACHE = upstream.CACHE_DIR
|
||||
ANON_QUOTA = 60
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
"""Emulator profiles confronted with their upstream source: citations, anchoring, reports and guarded profile writes."""
|
||||
@@ -32,7 +32,7 @@ import re
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass
|
||||
|
||||
import upstream
|
||||
from core import upstream
|
||||
|
||||
KINDS = ("file", "tag", "alias", "package", "none", "unverified")
|
||||
# Values copied from a .info or a branch name, which name no version.
|
||||
@@ -31,7 +31,7 @@ from model.profiles import source_yaml_paths
|
||||
from core.artifacts import write_text_atomic
|
||||
from model.safeparse import yaml_load
|
||||
|
||||
import upstream
|
||||
from core import upstream
|
||||
|
||||
from ._hash_merge import (
|
||||
_build_contents,
|
||||
|
||||
@@ -23,7 +23,7 @@ from pathlib import Path
|
||||
if (_SCRIPTS_DIR := str(Path(__file__).resolve().parents[2])) not in sys.path:
|
||||
sys.path.insert(0, _SCRIPTS_DIR)
|
||||
|
||||
import upstream
|
||||
from core import upstream
|
||||
from model.safeparse import yaml_load
|
||||
|
||||
CACHE_DIR = upstream.CACHE_DIR
|
||||
|
||||
@@ -14,7 +14,7 @@ from pathlib import Path
|
||||
import yaml
|
||||
|
||||
from . import Fetcher, SourceError, load_sources, scrape_setup
|
||||
from upstream import UpstreamError
|
||||
from core.upstream import UpstreamError
|
||||
from core.artifacts import write_text_atomic
|
||||
from ..base_scraper import _PlatformDumper
|
||||
|
||||
|
||||
@@ -15,10 +15,14 @@ from collections.abc import Iterator
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
import upstream
|
||||
from core import upstream
|
||||
from siterender import _by_mode, _escape_tags
|
||||
from sourceref import (
|
||||
_HEX_ADDRESS_RE, _prose_runs, is_binary_citation, ref_annotation, ref_role,
|
||||
from model.sourceref import (
|
||||
_HEX_ADDRESS_RE,
|
||||
_prose_runs,
|
||||
is_binary_citation,
|
||||
ref_annotation,
|
||||
ref_role,
|
||||
source_ref_values,
|
||||
split_source_ref,
|
||||
)
|
||||
|
||||
@@ -261,7 +261,7 @@ def _ref_cites_code(ref: str) -> bool:
|
||||
IL method says only that the binary exists: "import directory",
|
||||
"string table" and "readelf -d" are not the code that reads a file.
|
||||
"""
|
||||
from sourceref import split_source_ref
|
||||
from model.sourceref import split_source_ref
|
||||
|
||||
cited = False
|
||||
for part in split_source_ref(ref):
|
||||
|
||||
@@ -7804,7 +7804,7 @@ class PrboomPlusCitesFullPaths(unittest.TestCase):
|
||||
def test_every_cited_file_has_its_directory(self):
|
||||
import yaml
|
||||
|
||||
from scripts.sourceref import source_ref_values, split_source_ref
|
||||
from scripts.model.sourceref import source_ref_values, split_source_ref
|
||||
|
||||
profile = yaml.safe_load((ROOT / "emulators" / "prboom-plus.yml").read_text(encoding="utf-8"))
|
||||
refs: list[str] = []
|
||||
|
||||
@@ -13,7 +13,7 @@ import re
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import upstream
|
||||
from core import upstream
|
||||
from model.safeparse import yaml_load
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
@@ -13,7 +13,7 @@ import unittest
|
||||
from unittest import mock
|
||||
|
||||
import find_pinned_revision
|
||||
import upstream
|
||||
from core import upstream
|
||||
|
||||
|
||||
class ThePinnedRevisionIsInTheHistory(unittest.TestCase):
|
||||
|
||||
@@ -19,7 +19,7 @@ from pathlib import Path
|
||||
|
||||
SCRIPTS = Path(__file__).resolve().parent.parent / "scripts"
|
||||
|
||||
PACKAGE_LAYERS = {"core": 0, "model": 1, "resolve": 2, "scraper": 3, "exporter": 3}
|
||||
PACKAGE_LAYERS = {"core": 0, "model": 1, "resolve": 2, "scraper": 3, "exporter": 3, "profiling": 3}
|
||||
LIBRARY_LAYER = 3
|
||||
COMMAND_LAYER = 4
|
||||
|
||||
@@ -35,8 +35,7 @@ NOT_YET_PACKAGED = frozenset({
|
||||
"release_record", "romfolders", "romset_recipes", "siteagents", "sitebootstrap",
|
||||
"sitecollection", "sitediagrams", "siteentries", "siteexports", "siteguides", "sitehandheld",
|
||||
"siteinputs", "sitemarkup", "sitemeasurements", "siterender", "sitesources", "sitestarlight",
|
||||
"sitesteps", "sitewanted", "sitewrite", "slots", "sourceref", "split_pack", "upstream",
|
||||
"validate_pr", "verify", "version_basis",
|
||||
"sitesteps", "sitewanted", "sitewrite", "slots", "split_pack", "validate_pr", "verify",
|
||||
})
|
||||
|
||||
# Imports from a package module to a top-level module, left for the wave that
|
||||
@@ -44,9 +43,6 @@ NOT_YET_PACKAGED = frozenset({
|
||||
PENDING_TOP_LEVEL_IMPORTS = frozenset({
|
||||
("exporter.doubled", "slots"),
|
||||
("scraper.game_dat_importer", "region_audit"),
|
||||
("scraper.mame_hash_scraper", "upstream"),
|
||||
("scraper.romfolders", "upstream"),
|
||||
("scraper.romfolders.__main__", "upstream"),
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
import upstream
|
||||
from core import upstream
|
||||
from profile_sync import declared_repositories
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
@@ -59,9 +59,9 @@ from profile_sync import (
|
||||
watch_hashes,
|
||||
worst_status,
|
||||
)
|
||||
import upstream
|
||||
import version_basis
|
||||
from upstream import CompareResult, FileChange
|
||||
from core import upstream
|
||||
from profiling import version_basis
|
||||
from core.upstream import CompareResult, FileChange
|
||||
|
||||
|
||||
def _version_read_as_written(profile, cache_dir, offline, profiles=None, recompute=False):
|
||||
@@ -5856,7 +5856,7 @@ class ARecaleKeepsTheRepositoryWord(unittest.TestCase):
|
||||
path is read without the word, and a recale wrote it back without it."""
|
||||
|
||||
def test_the_word_stays_in_front_of_the_new_span(self):
|
||||
from sourceref import split_source_ref
|
||||
from model.sourceref import split_source_ref
|
||||
|
||||
for raw, expected in (
|
||||
("stella src/a.c:120-130", "stella src/a.c:140-150"),
|
||||
@@ -6014,7 +6014,7 @@ class ARoleIsReadPerPart(unittest.TestCase):
|
||||
self.assertEqual(prose[0].parts[0].repo, "alek/x")
|
||||
|
||||
def test_the_prose_grammar_keeps_the_role(self):
|
||||
from sourceref import _prose_runs
|
||||
from model.sourceref import _prose_runs
|
||||
|
||||
runs = list(_prose_runs(
|
||||
"# ref: source src/a.cpp:1656-1685, 1709-1738, upstream b.c:5"
|
||||
@@ -6027,7 +6027,7 @@ class ARoleIsReadPerPart(unittest.TestCase):
|
||||
def test_an_abbreviated_location_reads_in_the_file_named_last(self):
|
||||
"""devilutionx writes `Source/engine/assets.cpp:` then `(:507)` for
|
||||
each loader, and its pin moved under five uncollected numbers."""
|
||||
from sourceref import _prose_runs
|
||||
from model.sourceref import _prose_runs
|
||||
|
||||
text = (
|
||||
"Load order is defined in Source/engine/assets.cpp:\n"
|
||||
@@ -6053,7 +6053,7 @@ class ARoleIsReadPerPart(unittest.TestCase):
|
||||
])
|
||||
|
||||
def test_an_abbreviated_location_needs_a_file_before_it(self):
|
||||
from sourceref import _prose_runs
|
||||
from model.sourceref import _prose_runs
|
||||
|
||||
self.assertEqual(list(_prose_runs("read at boot (:507), devilutionx.mpq")), [])
|
||||
|
||||
|
||||
@@ -286,7 +286,7 @@ class CachedDirectory(unittest.TestCase):
|
||||
def test_file_missing_from_the_archive_is_absent(self) -> None:
|
||||
from unittest import mock
|
||||
|
||||
import upstream
|
||||
from core import upstream
|
||||
|
||||
fetcher = Fetcher({"os": {"repo": "https://gitlab.com/g/p", "commit": "0" * 40}})
|
||||
with mock.patch.object(upstream, "cache_gitlab_directory", return_value={"sys/a/system.ini"}):
|
||||
|
||||
@@ -63,7 +63,7 @@ from sitesources import launcher_ref_markdown, list_source
|
||||
import check_platform_folder
|
||||
import sitesources
|
||||
import release_record
|
||||
import upstream
|
||||
from core import upstream
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
@@ -924,7 +924,7 @@ class SourceLinksGoWhereTheFileIs(unittest.TestCase):
|
||||
continue
|
||||
for slug, pin, path in link.findall(
|
||||
sitesources._source_ref_markdown(profile, entry["source_ref"])):
|
||||
import upstream
|
||||
from core import upstream
|
||||
|
||||
repo = upstream.parse_repo(f"https://github.com/{slug}")
|
||||
held = sitesources.tree_holds(repo, pin, urllib.parse.unquote(path))
|
||||
|
||||
@@ -280,7 +280,7 @@ class CitationsKeepTheirAnnotations(unittest.TestCase):
|
||||
self.assertTrue(texts[4].endswith(")"), texts[4])
|
||||
|
||||
def test_the_annotation_is_what_follows_the_location(self):
|
||||
from sourceref import ref_annotation
|
||||
from model.sourceref import ref_annotation
|
||||
|
||||
self.assertEqual(ref_annotation("munt ROMInfo.cpp:206-213"), "")
|
||||
self.assertEqual(ref_annotation("source atari800/src/sysrom.c:91"), "")
|
||||
|
||||
@@ -19,9 +19,9 @@ from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
import sitesources
|
||||
import upstream
|
||||
from core import upstream
|
||||
from model.profiles import load_emulator_profiles
|
||||
from sourceref import ref_role, source_ref_values, split_source_ref
|
||||
from model.sourceref import ref_role, source_ref_values, split_source_ref
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
@@ -871,7 +871,7 @@ class TheGitHubTokenComesFromGh(unittest.TestCase):
|
||||
|
||||
def test_every_api_caller_reads_it(self):
|
||||
import profile_sync
|
||||
import upstream
|
||||
from core import upstream
|
||||
from scraper import base_scraper
|
||||
|
||||
with self._gh():
|
||||
@@ -888,7 +888,7 @@ class TheGitHubTokenComesFromGh(unittest.TestCase):
|
||||
profile_sync._check_quota(606, offline=False)
|
||||
|
||||
def test_another_forge_never_triggers_gh(self):
|
||||
import upstream
|
||||
from core import upstream
|
||||
|
||||
with self._gh() as run:
|
||||
headers = upstream._headers("https://gitlab.com/api/v4/projects/1")
|
||||
|
||||
@@ -15,8 +15,8 @@ import urllib.error
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
import upstream
|
||||
from upstream import make_repo, parse_repo, raw_url
|
||||
from core import upstream
|
||||
from core.upstream import make_repo, parse_repo, raw_url
|
||||
|
||||
|
||||
def _no_network(url: str):
|
||||
@@ -127,7 +127,7 @@ class TestRawUrl(unittest.TestCase):
|
||||
def test_forgejo_fetches_through_the_api(self):
|
||||
# git.ngram.ca serves an HTML proof-of-work page on /raw/commit,
|
||||
# which fetch_file would have cached as the file's lines.
|
||||
import upstream
|
||||
from core import upstream
|
||||
|
||||
repo = parse_repo("https://git.ngram.ca/mirrors/Ryujinx")
|
||||
self.assertEqual(
|
||||
|
||||
@@ -24,8 +24,8 @@ from unittest import mock
|
||||
import yaml
|
||||
|
||||
import profile_sync
|
||||
import upstream
|
||||
import version_basis
|
||||
from core import upstream
|
||||
from profiling import version_basis
|
||||
from model.profiles import load_emulator_profiles
|
||||
from profile_sync import ProfileReport, bump_commit
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ class DeploySiteTriggers(unittest.TestCase):
|
||||
"""sitesources imported two parsing functions from profile_sync, so
|
||||
every change to the comparison tool rebuilt an unchanged site."""
|
||||
self.assertNotIn("scripts/profile_sync.py", closure(["generate_site.py"]))
|
||||
self.assertIn("scripts/sourceref.py", closure(["generate_site.py"]))
|
||||
self.assertIn("scripts/model/sourceref.py", closure(["generate_site.py"]))
|
||||
|
||||
|
||||
class ThePullRequestBuildsTheSite(unittest.TestCase):
|
||||
|
||||
Reference in new issue
Block a user