473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to load plugins as objects?

Hi. I'm hoping for a bit of programming guidance here ....

I have an application I wrote (it's an irc bot fyi), with which I want to
use plugins.

Basically, I want there to be directory called plugins/ .

In plugins, there should be a bunch of *.py files. Each file should
contain a single class.

When the application launches, I want the interpreter to scan the
plugins/ dir for *.py files, and load each class in each every *.py file
as an object an object in memory.

I want it to so that every time I want the app to perform a new function,
I just write a plugin and stick it in the plugins/ directory.

What's the easiest way to go about this?
Jul 19 '05 #1
1 1720
"censored" <ce******@dontemailme.com> wrote:
Hi. I'm hoping for a bit of programming guidance here ....

I have an application I wrote (it's an irc bot fyi), with which I want to
use plugins.

Basically, I want there to be directory called plugins/ .

In plugins, there should be a bunch of *.py files. Each file should
contain a single class.

When the application launches, I want the interpreter to scan the
plugins/ dir for *.py files, and load each class in each every *.py file
as an object an object in memory.

I want it to so that every time I want the app to perform a new function,
I just write a plugin and stick it in the plugins/ directory.

What's the easiest way to go about this?


for file in glob.glob("plugins/*.py"):
ns = {}
execfile(file, ns)
for name, object in ns.items():
# pick out interesting objects

</F>

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Christoph Haas | last post by:
Dear coders... I'm working on an application that is supposed to support "plugins". The idea is to use the plugins as packages like this: Plugins/ __init__.py Plugin1.py Plugin2.py...
5
by: Rudolf Ball | last post by:
Dear NG, i want to load a plugin (WinForm) in my Applikation. That works fine. Now I want to globalize that plugin. So I have to load the Satellite Assembly, as well. But how can I load this...
4
by: Alan D. | last post by:
Hello. I was wondering if anybody had any good resources on creating browser plugins using C#. Right now I'm only worried about Internet Explorer plugins as I already have some documentation on...
5
by: Nikolay Petrov | last post by:
Can I load a class library at runtime? Plugins, etc?
7
by: petr pilsl | last post by:
sorry - no idea where to post my question, so I crossposted to a linux and a html-authoring-group. Both groups might be familiar with wget. wget -p http://www.goldfisch.at does not load the...
7
by: Chris | last post by:
Hi, first of all: sorry if this is not a pure C++ question, it is somewhat OS-specific but I think it fits here best. I have a base system with capabilities for loading plugings. Plugins...
0
by: treefrog | last post by:
Greetings, I have a C# application that uses Reflection to scan through a directory, ./plugins/, for assemblies that have been assigned the PluginAttribute and loads them. This part works...
1
by: pzero24 | last post by:
Ok so I am making plugins for my application and I have the plugins located in a subdirectory: /AppDir /AppDir/Plugins All my plugins reference a Plugins interface file, which is also located...
6
by: Dave Challis | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm trying to write some code which: 1. Finds all modules in a plugin directory 2. Imports those modules 3. Creates an instance of each object...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.