Kit manager menu oncesi

This commit is contained in:
2026-08-21 09:12:46 +03:00
parent 47bfaf04e0
commit b286b208da
8 changed files with 2501 additions and 970 deletions
+41 -20
View File
@@ -128,8 +128,39 @@ def compile_schema_registry(manifest_paths):
app_state.final_components_registry[type_name] = resolved_type_structure
def find_manifest_path(kit_name, checksum):
"""The manifest file describing a kit, or None when Sedona home holds none.
A declared checksum is honoured when its file exists; otherwise the last manifest by
filename is taken, the tolerance that lets a file with no checksums still open.
"""
manifest_dir = os.path.join(app_state.SEDONA_HOME, "manifests", kit_name)
if checksum:
target_file = os.path.join(manifest_dir, f"{kit_name}-{checksum}.xml")
if os.path.exists(target_file):
return target_file
if os.path.exists(manifest_dir):
files = [
f for f in os.listdir(manifest_dir)
if f.startswith(f"{kit_name}-") and f.endswith(".xml")
]
if files:
files.sort()
return os.path.join(manifest_dir, files[-1])
return None
def load_schema_kits_and_manifests():
"""Scans the schema block of the SAX file and maps/loads corresponding manifest definitions."""
"""Loads the manifests for the file's <schema> kits, plus any kit still only pending.
A component placed from the palette records its kit in ``pending_schema_kits`` rather
than writing to <schema> straight away — that reconciliation happens on save. Its
types still have to resolve now, or the box could not be painted, so pending kits are
compiled into the registry alongside the declared ones.
"""
app_state.active_schema_kits.clear()
if app_state.xml_root_element is None:
return
@@ -138,29 +169,19 @@ def load_schema_kits_and_manifests():
if schema_elem is None:
return
manifest_paths = []
missing_kits = []
for kit in schema_elem.findall("kit"):
name = kit.get("name")
checksum = kit.get("checksum")
if not name:
continue
app_state.active_schema_kits[name] = checksum
if name:
app_state.active_schema_kits[name] = kit.get("checksum")
manifest_dir = os.path.join(app_state.SEDONA_HOME, "manifests", name)
manifest_path = None
if checksum:
target_file = os.path.join(manifest_dir, f"{name}-{checksum}.xml")
if os.path.exists(target_file):
manifest_path = target_file
if not manifest_path and os.path.exists(manifest_dir):
files = [f for f in os.listdir(manifest_dir) if f.startswith(f"{name}-") and f.endswith(".xml")]
if files:
files.sort()
manifest_path = os.path.join(manifest_dir, files[-1])
kits_to_load = dict(app_state.active_schema_kits)
for name, checksum in app_state.pending_schema_kits.items():
kits_to_load.setdefault(name, checksum)
manifest_paths = []
missing_kits = []
for name, checksum in kits_to_load.items():
manifest_path = find_manifest_path(name, checksum)
if manifest_path:
manifest_paths.append(manifest_path)
else: