Python Forum

Full Version: managing modules/scripts dynamically
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a collection of scripts and modules that I want to integrate into an application{CLI for now}. The application needs to be able to list all the scripts and its basic usage.Now the problem is the scripts can be changed, new ones can be added or the user can also choose which ones to add into his application.

-I want this without having to restrict scripts implementation(having then inherit from a class with certain methods)
Something similar to pip...
Is there a python library for this kinda stuff or I have to implement a system myself.

My initial approach is to use .ini or json to store some mandatory settings or options and a static relative path to main.py to store the scripts.But it does not help with adding scripts later on as users cant be trusted for setting up .ini and json files.

any suggestion is much appreciated.
If they're all in a sub-directory, you could just list the contents of the directory.  Or, you could import anything in the file, and use magic variables in each file (such as __doc__ or __name__) to display a menu and help.
(Oct-06-2017, 04:55 PM)nilamo Wrote: [ -> ]If they're all in a sub-directory, you could just list the contents of the directory.  Or, you could import anything in the file, and use magic variables in each file (such as __doc__ or __name__) to display a menu and help.
thats what it was thinking but it doesn't help with adding scripts to that subdirectory ....Like pip does. If I have 5 scripts on remote server and I only want 3 of them i just download them and they get added to that subdirectory.