[kupfer] plugin.rst: reStructuredText
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] plugin.rst: reStructuredText
- Date: Fri, 25 Sep 2009 15:54:03 +0000 (UTC)
commit cfdb1c2c91f5ee3e9b39574728fa489d9f3607e6
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Sat Sep 19 23:56:54 2009 +0200
plugin.rst: reStructuredText
kupfer/plugin/rst.py | 36 ++++++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/plugin/rst.py b/kupfer/plugin/rst.py
new file mode 100644
index 0000000..2c265a7
--- /dev/null
+++ b/kupfer/plugin/rst.py
@@ -0,0 +1,36 @@
+import docutils.core
+import os
+
+from kupfer.objects import Source, Action, TextLeaf, FileLeaf
+from kupfer import utils, icons
+
+__kupfer_name__ = _("reStructuredText")
+__kupfer_actions__ = ("RenderView", )
+__description__ = _("Render reStructuredText and show the result")
+__version__ = ""
+__author__ = "Ulrik Sverdrup <ulrik sverdrup gmail com>"
+
+class RenderView (Action):
+ def __init__(self):
+ Action.__init__(self, _("View as HTML Document"))
+
+ def activate(self, leaf):
+ finput = open(leaf.object, "rb")
+ (foutput, fpath) = utils.get_safe_tempfile()
+ try:
+ parsed_content = docutils.core.publish_file(finput,
+ destination=foutput,
+ writer_name="html")
+ finally:
+ finput.close()
+ foutput.close()
+ utils.show_path(fpath)
+ def item_types(self):
+ yield FileLeaf
+ def valid_for_item(self, leaf):
+ root, ext = os.path.splitext(leaf.object)
+ return ext.lower() in (".rst", ".rest", ".txt")
+ def get_description(self):
+ return __description__
+ def get_gicon(self):
+ return icons.ComposedIcon(Action.get_icon_name(self), "python")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]