Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meta issue referencing extension updates #2041

Open
jcfr opened this issue Apr 24, 2024 · 3 comments
Open

Meta issue referencing extension updates #2041

jcfr opened this issue Apr 24, 2024 · 3 comments

Comments

@jcfr
Copy link
Member

jcfr commented Apr 24, 2024

These pull requests were created in the context of #2011

List of pull requests intended to fix and consolidate extension metadata:

@jcfr jcfr pinned this issue Apr 24, 2024
@fedorov
Copy link
Member

fedorov commented Apr 24, 2024

@jcfr can you please review this comment: QIICR/SlicerDevelopmentToolbox#45 (comment) ?

Extension build stopped working today, which coincided with your PR...

@jcfr
Copy link
Member Author

jcfr commented Apr 24, 2024

Thanks for pointing this out, I will have a look later when back on the 👨‍💻

@jcfr
Copy link
Member Author

jcfr commented May 1, 2024

List of pull requests and issues intended to fix and consolidate extension metadata for extension not yet integrated:

For future reference, following code was used to generate the s4ext from json:

import json
import sys
from pathlib import Path

extensions_index_dir = Path("/home/jcfr/Projects/ExtensionsIndex")
updated_extensions_index_dir = extensions_index_dir

def parse_s4ext(ext_file_path):
    """Parse a Slicer extension description file.
    :param ext_file_path: Path to a Slicer extension description file.
    """
    ext_metadata = {}
    with open(ext_file_path) as ext_file:
        for line in ext_file:
            if not line.strip() or line.startswith("#"):
                continue
            fields = [field.strip() for field in line.split(' ', 1)]
            assert(len(fields) <= 2)
            ext_metadata[fields[0]] = fields[1] if len(fields) == 2 else None
    return ext_metadata

# Collect s4ext files
s4ext_filepaths = list(extensions_index_dir.glob("*.s4ext"))

print(f"Found {len(s4ext_filepaths)} extension files (.s4ext)")

# Parse s4ext files and generate corresponding json files
for index, filepath in enumerate(s4ext_filepaths):

    metadata = parse_s4ext(filepath)
    #print("filepath", filepath)
    updated_metadata = {
        "$schema": "https://raw.githubusercontent.com/Slicer/Slicer/main/Schemas/slicer-extension-catalog-entry-schema-v1.0.0.json#",
        "scm_url": metadata["scmurl"],
        "scm_revision": metadata["scmrevision"],
        "build_dependencies": [] if metadata.get("depends", "NA") == "NA" else metadata["depends"].split(" "),
        "category": metadata["category"],
        "build_subdirectory": metadata["build_subdirectory"],
    }

    with open(updated_extensions_index_dir / f"{filepath.stem}.json", 'w') as fileContents:
        fileContents.write(json.dumps(updated_metadata, sort_keys=True, indent=2))
        fileContents.write("\n")

print(f"Generated {index + 1} extension files (.json)")

from pprint import pprint as pp

print(f"\nMetadata of extension #{index + 1} ({filepath.stem}):\n")
pp(updated_metadata)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants