summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSteve 'Ashcrow' Milner <stevem@gnulinux.net>2008-02-23 22:03:08 -0500
committerSteve 'Ashcrow' Milner <stevem@gnulinux.net>2008-02-23 22:03:08 -0500
commite27f9d8383848d523d301706046c54e99b5f9676 (patch)
tree2d1e80e380d9ab364e6fe8b42be1c1584aa695af /scripts
parent737d7ddb4f712a35b5d4cb754f57572980ce1721 (diff)
downloadfunc-e27f9d8383848d523d301706046c54e99b5f9676.tar.gz
func-e27f9d8383848d523d301706046c54e99b5f9676.tar.xz
func-e27f9d8383848d523d301706046c54e99b5f9676.zip
allow ctrl+c and make sure we get input.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/func-create-module52
1 files changed, 33 insertions, 19 deletions
diff --git a/scripts/func-create-module b/scripts/func-create-module
index 0250006..4786cb0 100755
--- a/scripts/func-create-module
+++ b/scripts/func-create-module
@@ -73,29 +73,43 @@ def get_email():
regx = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"
while True:
- author_email = raw_input("Email: ")
+ author_email = get_input("Email")
if re.match(regx, author_email) != None:
break
print "Please enter a valid email!"
return author_email
+def get_input(prompt):
+ """
+ Get input and make sure input is given.
+ """
+ result = raw_input("%s: " % prompt)
+ if not result:
+ print "Please input the requested information."
+ return get_input(prompt)
+ return result
+
+
if __name__ == '__main__':
- MODULE_NAME = raw_input("Module Name: ").capitalize()
- DESC = raw_input("Description: ")
- AUTHOR_NAME = raw_input("Author: ")
- AUTHOR_EMAIL = get_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
+ try:
+ MODULE_NAME = get_input("Module Name").capitalize()
+ DESC = get_input("Description")
+ AUTHOR_NAME = get_input("Author")
+ AUTHOR_EMAIL = get_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
+ except KeyboardInterrupt, ex:
+ print "\nExiting ..."