X-Git-Url: https://pwan.org/git/?p=certmaster.git;a=blobdiff_plain;f=scripts%2Ffunc-create-module;fp=scripts%2Ffunc-create-module;h=f2885e8e2061a0c6847251358cd3092960e56ec4;hp=0000000000000000000000000000000000000000;hb=697402da24ca930b3608359a61b9872fdddc62d9;hpb=ac3061bcffd2ea634596c188beaa13339e3fa24a diff --git a/scripts/func-create-module b/scripts/func-create-module new file mode 100755 index 0000000..f2885e8 --- /dev/null +++ b/scripts/func-create-module @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# +# Copyright 2008, Red Hat, Inc +# Steve 'Ashcrow' Milner +# John Eckersberg +# +# 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 = """\ +# +# Copyright %s +# %s <%s> +# +# 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. + +import func_module + +class %s(func_module.FuncModule): + + # Update these if need be. + version = "0.0.1" + api_version = "0.0.1" + description = "%s" + +%s +""" + +METHOD_TEMPLATE = '''\ + def %s(self): + """ + TODO: Document me ... + """ + pass + +''' + + +def populate_template(author_name, author_email, module_name, desc, methods): + """ + Makes the method strings and populates the template. + """ + from datetime import datetime + + actual_methods = "" + for method in methods: + actual_methods += METHOD_TEMPLATE % method + return TEMPLATE % (datetime.now().strftime("%Y"), author_name, + author_email, module_name, desc, actual_methods[:-2]) + + +if __name__ == '__main__': + module_name = raw_input("Module Name: ").capitalize() + desc = raw_input("Description: ") + author_name = raw_input("Author: ") + author_email = raw_input("Email: ") + 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(author_name, author_email, + module_name, desc, methods)) + file_obj.close() + print "Your module is ready to be hacked on. Wrote out to %s." % file_name