File: plugin_manifest.py

package info (click to toggle)
python-enaml 0.19.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,284 kB
  • sloc: python: 31,443; cpp: 4,499; makefile: 140; javascript: 68; lisp: 53; sh: 20
file content (66 lines) | stat: -rw-r--r-- 2,061 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#------------------------------------------------------------------------------
# Copyright (c) 2013-2025, Nucleic Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
#------------------------------------------------------------------------------
from atom.api import Callable, ForwardTyped, Str

from enaml.core.declarative import Declarative, d_

from .extension import Extension
from .extension_point import ExtensionPoint


def Workbench():
    """ A lazy forward import function for the Workbench type.

    """
    from .workbench import Workbench
    return Workbench


def plugin_factory():
    """ A factory function which returns a plain Plugin instance.

    """
    from .plugin import Plugin
    return Plugin()


class PluginManifest(Declarative):
    """ A declarative class which represents a plugin manifest.

    """
    #: The globally unique identifier for the plugin. The suggested
    #: format is dot-separated, e.g. 'foo.bar.baz'.
    id = d_(Str())

    #: The factory which will create the Plugin instance. It should
    #: take no arguments and return an instance of Plugin. Well behaved
    #: applications will make this a function which lazily imports the
    #: plugin class so that startup times remain small.
    factory = d_(Callable(plugin_factory))

    #: The workbench instance with which this manifest is registered.
    #: This is assigned by the framework and should not be manipulated
    #: by user code.
    workbench = ForwardTyped(Workbench)

    #: An optional description of the plugin.
    description = d_(Str())

    @property
    def extensions(self):
        """ Get the list of extensions defined by the manifest.

        """
        return [c for c in self.children if isinstance(c, Extension)]

    @property
    def extension_points(self):
        """ Get the list of extensions points defined by the manifest.

        """
        return [c for c in self.children if isinstance(c, ExtensionPoint)]