How does Builder know which object is the plugin in a Python file?

From the docs, what we do is make a .plugin file and tell Builder which file (Module) to look and if it is Python (Loader).

# my_plugin.plugin
[Plugin]
Name=My Plugin
Loader=python3
Module=my_plugin
Author=Angela Avery

Now how does Builder know which class in the file is the plugin and which one should be initialized ? Does it use of help of ast module? (A Python module to make syntax tree for a Python file). Like parsing the file, getting all the declared classes and check if they are instance of an abstract plugin class?

I want to mimic a kinda same behaviour for my plugin system and curiosity are the reasons for this question. :smiley:

Builder uses libpeas so in the case of Python plugins, I believe it determines which class is a plugin based on what GObject Interfaces it implements (or abstract class it derives from).

1 Like

So I think I’m kinda right in what I guessed.

1 Like

Oops, I didn’t actually see the bottom part of your question :stuck_out_tongue:

Yes, your guess was right. Of course, you can always use the .plugin file and add extra fields to make that easier. Looking at the docs/code for PeasEngine might be useful for some ideas, too.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.