[gedit-plugins] Improved new-command template
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-plugins] Improved new-command template
- Date: Sun, 14 Mar 2010 22:52:35 +0000 (UTC)
commit 324904581018de90a002ce9de033d65e80a98059
Author: Jesse van den Kieboom <jesse icecrew nl>
Date: Sun Mar 14 23:50:35 2010 +0100
Improved new-command template
plugins/commander/modules/edit.py | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/plugins/commander/modules/edit.py b/plugins/commander/modules/edit.py
index 1dc96fa..c6ea5e6 100644
--- a/plugins/commander/modules/edit.py
+++ b/plugins/commander/modules/edit.py
@@ -169,6 +169,20 @@ def command(view, name):
raise commander.commands.exceptions.Execute('Could not find command: ' + name)
+COMMAND_TEMPLATE="""import commander.commands as commands
+import commander.commands.completion
+import commander.commands.result
+import commander.commands.exceptions
+
+__commander_module__ = True
+
+def __default__(view, entry):
+ \"\"\"Some kind of cool new feature: cool <something>
+
+Use this to apply the cool new feature\"\"\"
+ pass
+"""
+
def new_command(view, entry, name):
"""Create a new commander command module: edit.new-command <command>"""
@@ -176,9 +190,12 @@ def new_command(view, entry, name):
if os.path.isfile(filename):
raise commander.commands.exceptions.Execute('Commander module `' + name + '\' already exists')
-
+
+ dirname = os.path.dirname(filename)
+ os.makedirs(dirname)
+
f = open(filename, 'w')
- f.write("import commander.commands\n\n__commander_module__ = True\n\ndef __default__(view, entry):\n\t\"\"\"Some kind of cool new feature: cool <something>\n\nUse this to apply the cool new feature\"\"\"\n\tpass\n")
+ f.write(COMMAND_TEMPLATE)
f.close()
return __default__(filename, view)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]