From 2e7f8857586f196b5434e3ce9a41a604cbf08f29 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Sun, 21 Dec 2008 16:23:47 +0100 Subject: Plugin creator script --- lib/python/Plugins/newplugin.py | 104 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 lib/python/Plugins/newplugin.py (limited to 'lib/python/Plugins/newplugin.py') diff --git a/lib/python/Plugins/newplugin.py b/lib/python/Plugins/newplugin.py new file mode 100644 index 00000000..6a448407 --- /dev/null +++ b/lib/python/Plugins/newplugin.py @@ -0,0 +1,104 @@ +#!/usr/bin/python + +import os + +name = raw_input("Plugin name: ") + +print + +dirlist = [] +count = 0 +print "Plugin categories:" +for dir in os.listdir("."): + if os.path.isdir(dir): + count += 1 + dirlist.append(dir) + print count, dir + +category = raw_input("Select plugin category: ") +category = dirlist[int(category) - 1] + +def add_where_extensionsmenu(name, fnc): + description = raw_input("Plugin description: ") + return 'PluginDescriptor(name = "%s", description = _("%s"), where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc = %s)' % (name, description, fnc) + +def add_where_pluginmenu(name, fnc): + description = raw_input("Plugin description: ") + icon = raw_input("Icon (default: 'plugin.png': ") + if icon == "": + icon = "plugin.png" + return 'PluginDescriptor(name = "%s", description = _("%s"), icon = "%s", where = PluginDescriptor.WHERE_PLUGINMENU, fnc = %s)' % (name, description, icon, fnc) + +wherelist = [] +wherelist.append(("WHERE_EXTENSIONSMENU", add_where_extensionsmenu)) +wherelist.append(("WHERE_PLUGINMENU", add_where_extensionsmenu)) + +targetlist = [] + +stop = False + +while not stop: + os.system("clear") + print "selected targets:" + for where in targetlist: + print where[0] + + print + print "available targets:" + count = 0 + for where in wherelist: + count += 1 + print count, where[0] + print "x break" + + target = raw_input("Select WHERE-target: ") + if target == "x": + stop = True + else: + if wherelist[int(target) - 1] not in targetlist: + targetlist.append(wherelist[int(target) - 1]) + else: + targetlist.remove(wherelist[int(target) - 1]) + + +file = open("plugin.py", "w") + +importlist = [] +for where in targetlist: + importlist.append(where[0]) + +file.write("""from Screens.Screen import Screen +from Plugins.Plugin import PluginDescriptor, %s +""" % ', '.join(importlist)) + +mainlist = [] +for count in range(len(targetlist)): + if count == 0: + mainlist.append("main") + else: + mainlist.append("main" + str(count)) + +for main in mainlist: + file.write(""" +def %s(session, **kwargs): + pass +""" % main) + +descriptorlist = [] +for count in range(len(targetlist)): + os.system("clear") + where = targetlist[count] + print "Options for target %s" % where[0] + descriptorlist.append(where[1](name, mainlist[count])) + +if len(descriptorlist) == 1: + descriptorlist = descriptorlist[0] +else: + descriptorlist = "[" + ', '.join(descriptorlist) + "]" + +file.write(""" +def Plugins(**kwargs): + return %s + """ % descriptorlist) + +file.close() \ No newline at end of file -- cgit v1.2.3 From 63d61a6e5ad877013cb450f3afad591e7ff22587 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Sun, 21 Dec 2008 16:50:16 +0100 Subject: create directory for plugin and add plugin to configure.ac and Makefile.am --- lib/python/Plugins/newplugin.py | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'lib/python/Plugins/newplugin.py') diff --git a/lib/python/Plugins/newplugin.py b/lib/python/Plugins/newplugin.py index 6a448407..c84f0609 100644 --- a/lib/python/Plugins/newplugin.py +++ b/lib/python/Plugins/newplugin.py @@ -2,10 +2,12 @@ import os -name = raw_input("Plugin name: ") - +os.system("clear") +internalname = raw_input("Internal plugin name (no whitespaces, plugin directory): ") +name = raw_input("Visible plugin name: ") print +os.system("clear") dirlist = [] count = 0 print "Plugin categories:" @@ -31,7 +33,7 @@ def add_where_pluginmenu(name, fnc): wherelist = [] wherelist.append(("WHERE_EXTENSIONSMENU", add_where_extensionsmenu)) -wherelist.append(("WHERE_PLUGINMENU", add_where_extensionsmenu)) +wherelist.append(("WHERE_PLUGINMENU", add_where_pluginmenu)) targetlist = [] @@ -61,7 +63,38 @@ while not stop: targetlist.remove(wherelist[int(target) - 1]) -file = open("plugin.py", "w") +pluginpath = category + "/" + internalname +os.mkdir(pluginpath) + +makefile = open(category + "/Makefile.am", "r") +lines = makefile.readlines() +lines = ''.join(lines) +lines = lines.strip() +lines += " " + internalname +makefile.close() + +makefile = open(category + "/Makefile.am", "w") +makefile.write(lines) +makefile.close() + +lines = [] +print "open" +configure = open("../../../configure.ac", "r") +while True: + line = configure.readline() + if not line: + break + lines.append(line) + if line.strip() == "lib/python/Plugins/" + category + "/Makefile": + lines.append("lib/python/Plugins/" + pluginpath + "/Makefile\n") +configure.close() +print "close" + +configure = open("../../../configure.ac", "w") +configure.writelines(lines) +configure.close() + +file = open(pluginpath + "/plugin.py", "w") importlist = [] for where in targetlist: -- cgit v1.2.3 From 3378afcd273524b5cb88b1245ff14b786e968ab8 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Sun, 21 Dec 2008 16:56:38 +0100 Subject: create Makefile.am automatically --- lib/python/Plugins/newplugin.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib/python/Plugins/newplugin.py') diff --git a/lib/python/Plugins/newplugin.py b/lib/python/Plugins/newplugin.py index c84f0609..48bb28ea 100644 --- a/lib/python/Plugins/newplugin.py +++ b/lib/python/Plugins/newplugin.py @@ -134,4 +134,13 @@ def Plugins(**kwargs): return %s """ % descriptorlist) -file.close() \ No newline at end of file +file.close() + +makefile = open(pluginpath + "/Makefile.am", "w") +makefile.write("""installdir = $(LIBDIR)/enigma2/python/Plugins/%s/%s + +install_PYTHON = \\ + __init__.py \\ + plugin.py +""" % (category, internalname)) +makefile.close() -- cgit v1.2.3