refactor: one predicate for the pack notes

This commit is contained in:
Abdessamad Derraz committed 2026-11-21 19:50:33 +01:00
1 parent 66c83b06b0
commit cf7e13808f
7 files changed
+30 -32

No files matched your search

-9
View File
@@ -3,18 +3,9 @@
from __future__ import annotations
import os
import re
from core.paths import EMULATORS_DIR
from model.registry import load_data_dir_registry
from packs.paths import MEDIA_MARKER
# Members the builder writes for the reader or the device rather than for a
# core: the documents, and the empty marker an Android pack carries.
PACK_NOTES = re.compile(
r"(^README\.txt$|^manifest\.json$|(^|/)(INSTRUCTIONS|RENAMED)_[^/]*\.txt$"
rf"|(^|/){re.escape(MEDIA_MARKER)}$)"
)
def tree_members(
+2 -1
View File
@@ -6,6 +6,7 @@ from pathlib import Path
from core.paths import PLATFORMS_DIR
from orchestrate import compare
from packs.archive import is_pack_note
from orchestrate.labels import STEP_LABELS, step_title
from orchestrate.reports import (
match_key,
@@ -138,7 +139,7 @@ def check_pack_destinations(
written = {
info.filename for info in zf.infolist()
if not info.is_dir()
and not compare.PACK_NOTES.search(info.filename)
and not is_pack_note(info.filename)
and not (
trees.get(info.filename) == info.file_size
and info.filename not in credited
+3 -2
View File
@@ -6,8 +6,9 @@ import contextlib
import io
from core.paths import DB_FILE, EMULATORS_DIR, PLATFORMS_DIR
from orchestrate.compare import PACK_NOTES, comparison_inputs, set_difference_lines
from orchestrate.compare import comparison_inputs, set_difference_lines
from orchestrate.labels import STEP_LABELS, step_title
from packs.archive import is_pack_note
# How each pack_narrowings() dimension of a platform pack is compared by
# check_narrowed_packs, or why it is not. A test reads the builder's
@@ -142,7 +143,7 @@ def check_narrowed_packs(
trees = set(record.trees) - credited
written = {
m for m in record.members
if not PACK_NOTES.search(m) and m not in trees
if not is_pack_note(m) and m not in trees
}
lines = set_difference_lines(name, credited, written)
if lines:
+4 -3
View File
@@ -8,8 +8,9 @@ from collections.abc import Callable
from typing import TYPE_CHECKING
from core.paths import DB_FILE, EMULATORS_DIR, PLATFORMS_DIR
from orchestrate.compare import PACK_NOTES, comparison_inputs
from orchestrate.compare import comparison_inputs
from orchestrate.labels import STEP_LABELS, step_title
from packs.archive import is_pack_note
if TYPE_CHECKING:
from packs.archive import PackRecord
@@ -23,10 +24,10 @@ def split_differences(
A path in a part and not in the full pack, a path of the full pack in no
part, and a path a part fills with other bytes than the full pack.
"""
full_members = {m for m in full.members if not PACK_NOTES.search(m)}
full_members = {m for m in full.members if not is_pack_note(m)}
union = {
m for record in parts.values() for m in record.members
if not PACK_NOTES.search(m)
if not is_pack_note(m)
}
lines = [f"in a part, not in the full pack: {m}" for m in sorted(union - full_members)]
lines += [f"in the full pack, in no part: {m}" for m in sorted(full_members - union)]