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

Add PluginManager dict() method to export state of manager #197

Merged
merged 2 commits into from
Jun 25, 2022

Conversation

tlambert03
Copy link
Collaborator

@tlambert03 tlambert03 commented Jun 24, 2022

This adds a dict() method, akin to the BaseModel.dict() method on the manifests, that allows the state of the plugin manager to be exported, allowing for include and exclude arguments to be passed to each manifest dict() method.

This will come in handy for the npe2 list command line argument (#192 ) (but also provides a direct programmatic way)

In [8]: pm.dict(include={'contributions'}, exclude={'contributions.commands', 'contributions.themes'})
Out[8]:
{
    'plugins': {
        'napari-svg': {
            'contributions': {
                'readers': None,
                'writers': [
                    {'command': 'napari-svg.svg_writer', 'layer_types': ['image*', 'labels*', 'points*', 'shapes*', 'vectors*'], 'filename_extensions': ['.svg'], 'display_name': ''}
                ],
                'widgets': None,
                'sample_data': None,
                'menus': {},
                'submenus': None
            }
        }
    },
    'disabled': set(),
    'activated': set()
}

@tlambert03 tlambert03 marked this pull request as ready for review June 24, 2022 14:51
@codecov
Copy link

codecov bot commented Jun 24, 2022

Codecov Report

Merging #197 (cd2f8e4) into main (d38a34c) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #197   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           30        30           
  Lines         2083      2106   +23     
=========================================
+ Hits          2083      2106   +23     
Impacted Files Coverage Δ
npe2/_plugin_manager.py 100.00% <100.00%> (ø)
npe2/plugin_manager.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d38a34c...cd2f8e4. Read the comment docs.

Copy link
Collaborator

@nclack nclack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@tlambert03 tlambert03 merged commit 2323319 into napari:main Jun 25, 2022
@tlambert03 tlambert03 deleted the plugin-manager-dict branch June 25, 2022 00:25
@tlambert03 tlambert03 added the enhancement New feature or request label Jun 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants