Python Forum
managing modules/scripts dynamically - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: managing modules/scripts dynamically (/thread-5479.html)



managing modules/scripts dynamically - hbknjr - Oct-06-2017

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.


RE: managing modules/scripts dynamically - nilamo - Oct-06-2017

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.


RE: managing modules/scripts dynamically - hbknjr - Oct-06-2017

(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.