summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSteve 'Ashcrow' Milner <stevem@gnulinux.net>2008-01-13 14:06:05 -0500
committerSteve 'Ashcrow' Milner <stevem@gnulinux.net>2008-01-13 14:06:05 -0500
commit2fad9189600fb3d3e6b695152c3512e5f22271a8 (patch)
tree0820eecb5dfe8f195800bf372251005aa8bfd7c3 /scripts
parent421ff0639e74b52ac723ed53c0368b2c980b838f (diff)
downloadfunc-2fad9189600fb3d3e6b695152c3512e5f22271a8.tar.gz
func-2fad9189600fb3d3e6b695152c3512e5f22271a8.tar.xz
func-2fad9189600fb3d3e6b695152c3512e5f22271a8.zip
Added in func-create-module to make boilerplate module code. spec, setup and version updated as well.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/func-create-module66
1 files changed, 66 insertions, 0 deletions
diff --git a/scripts/func-create-module b/scripts/func-create-module
new file mode 100755
index 0000000..afb4d09
--- /dev/null
+++ b/scripts/func-create-module
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+# Steve 'Ashcrow' Milner <smilner@redhat.com>
+# John Eckersberg <jeckersb@redhat.com>
+#
+# This software may be freely redistributed under the terms of the GNU
+# general public license.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+TEMPLATE = """\
+from modules import func_module
+# Add your imports here
+import sub_process
+
+class %s(func_module.FuncModule):
+
+ # Update these if need be.
+ version = "0.0.1"
+ api_version = "0.0.1"
+ description = "%s"
+
+ def __init__(self):
+ self.methods = {
+%s
+ }
+ func_module.FuncModule.__init__(self)
+
+%s
+
+
+methods = %s()
+register_rpc = methods.register_rpc
+"""
+
+
+def populate_template(module_name, desc, methods):
+ """
+ Makes the method strings and populates the template.
+ """
+ actual_methods = ""
+ method_str_dict = ""
+ for method in methods:
+ method_str_dict += ' "%s": self.%s,\n' % (method, method)
+ actual_methods += " def self.%s(self):\n pass\n\n" % method
+ return TEMPLATE % (module_name, desc,
+ method_str_dict[:-1], actual_methods[:-2], module_name)
+
+
+if __name__ == '__main__':
+ module_name = raw_input("Name: ").capitalize()
+ desc = raw_input("Description: ")
+ methods = []
+ print "\nLeave blank to finish."
+ while True:
+ method = raw_input("Method: ")
+ if method == '':
+ break
+ methods.append(method)
+ # Write it out to a file
+ file_name = "%s.py" % module_name.lower()
+ file_obj = open(file_name, "w")
+ file_obj.write(populate_template(module_name, desc, methods))
+ file_obj.close()
+ print "Your module is ready to be hacked on. Wrote out to %s." % file_name \ No newline at end of file