Add the metadata file path for easy copy+paste

This commit is contained in:
Kylian Schmidt
2025-07-29 11:18:03 +02:00
parent bcb083bbb9
commit fc4928fef1
5 changed files with 243 additions and 8 deletions
+26 -3
View File
@@ -50,7 +50,7 @@ def load_metadata_file(metadata_path: Path) -> Dict[str, Any]:
def load_folder_metadata(folder_path: Path) -> Dict[str, Any]:
"""
Load folder-level metadata from meta.yaml, meta.json, or metadata.json.
Load folder-level metadata from metadata.yaml, metadata.yml, or metadata.json.
Args:
folder_path: Path to the folder to check for metadata
@@ -58,8 +58,8 @@ def load_folder_metadata(folder_path: Path) -> Dict[str, Any]:
Returns:
Dictionary containing the folder metadata
"""
# Try YAML first, then JSON (including metadata.json for backwards compatibility)
for filename in ['meta.yaml', 'meta.yml', 'meta.json', 'metadata.json']:
# Try YAML first, then JSON for backwards compatibility
for filename in ['metadata.yaml', 'metadata.yml', 'metadata.json']:
metadata_path = folder_path / filename
if metadata_path.exists():
return load_metadata_file(metadata_path)
@@ -67,6 +67,29 @@ def load_folder_metadata(folder_path: Path) -> Dict[str, Any]:
return {}
def get_metadata_file_path(folder_path: Path) -> str:
"""
Get the metadata file path for a folder. Returns existing file if found,
otherwise suggests metadata.yaml (preferred format).
Args:
folder_path: Path to the folder to check for metadata
Returns:
String path to the metadata file (existing or suggested)
"""
# Preferred order: YAML first, then JSON
preferred_files = ['metadata.yaml', 'metadata.yml', 'metadata.json']
for filename in preferred_files:
metadata_path = folder_path / filename
if metadata_path.exists():
return str(metadata_path)
# If no file exists, suggest metadata.yaml (preferred format)
return str(folder_path / 'metadata.yaml')
def merge_metadata(
parent_metadata: Dict[str, Any],
child_metadata: Dict[str, Any]