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

Collect napari-plugins #507

Open
haesleinhuepf opened this issue Nov 20, 2024 · 1 comment
Open

Collect napari-plugins #507

haesleinhuepf opened this issue Nov 20, 2024 · 1 comment

Comments

@haesleinhuepf
Copy link
Member

The website napari-hub.org has an API which can be used to list all napari plugins, e.g. like this:

def get_all_plugin_data():
    url = 'https://api.napari-hub.org/plugins/index'

    json_url = urllib.request.urlopen(url) 
    data = json.loads(json_url.read()) 
    return data

def get_plugin_index():
    data = get_all_plugin_data()
    return list([x['name'] for x in data])

all_plugins = get_plugin_index()`

Furthermore, it should be possible to determine the corresponding github repository urls from these plugins, preferably using the pypi API (all napari plugins are on pypi).

git-bob think about code to list urls of github repositories of all napari plugins.

Copy link
Contributor

This message was generated by git-bob (version: 0.14.0, model: github_models:gpt-4o, log), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

To list GitHub repository URLs for all Napari plugins, you can extend the existing code. Here's a proposal:

import urllib.request
import json

def get_all_plugin_data():
    url = 'https://api.napari-hub.org/plugins/index'
    json_url = urllib.request.urlopen(url)
    data = json.loads(json_url.read())
    return data

def get_plugin_index():
    data = get_all_plugin_data()
    return list([x['name'] for x in data])

def get_github_urls():
    plugin_names = get_plugin_index()
    github_urls = []
    for plugin in plugin_names:
        try:
            url = f'https://pypi.org/pypi/{plugin}/json'
            response = urllib.request.urlopen(url)
            plugin_data = json.loads(response.read())
            project_urls = plugin_data['info']['project_urls']
            github_url = project_urls.get('Source') or project_urls.get('Homepage')
            if github_url and 'github.com' in github_url:
                github_urls.append(github_url)
        except Exception as e:
            print(f"Failed to get data for {plugin}: {e}")
    return github_urls

all_github_urls = get_github_urls()

This code retrieves the GitHub URLs of Napari plugins using the PyPI API.

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

No branches or pull requests

1 participant