Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/taexporthtml.py
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2010-03-11 19:02:59 (GMT)
committer Walter Bender <walter@sugarlabs.org>2010-03-11 19:02:59 (GMT)
commitb9029092b88a641f8ff89d8a22c724201d2f40b0 (patch)
tree644f9a3a80b04145d3128413a081071bb8b16054 /taexporthtml.py
parent05f5b51a7363bad3eb9ccb86435611ae6091c0a8 (diff)
pylint cleanup
Diffstat (limited to 'taexporthtml.py')
-rw-r--r--taexporthtml.py64
1 files changed, 32 insertions, 32 deletions
diff --git a/taexporthtml.py b/taexporthtml.py
index 6589b03..5a0d163 100644
--- a/taexporthtml.py
+++ b/taexporthtml.py
@@ -21,33 +21,26 @@
import pygtk
pygtk.require('2.0')
import gtk
-try:
- from sugar.activity import activity
- from sugar.datastore import datastore
-except ImportError:
- pass
import os.path
-from talogo import get_pixbuf_from_journal
-from tautils import data_to_string, save_picture, image_to_base64, get_path
+from tautils import data_to_string, save_picture, image_to_base64
from gettext import gettext as _
def save_html(self, tw, embed_flag=True):
-
+ """ Either: Save canvas and code or pictures to HTML """
self.embed_images = embed_flag
# A dictionary to define the HTML wrappers around template elements
self.html_glue = {
- 'doctype': "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 "+\
+ 'doctype': "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 " + \
"Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n",
'html': ("<html>\n", "</html>\n"),
'html_svg': ("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n",
"</html>\n"),
'head': ("<head>\n<!-- Created by Turtle Art -->\n", "</head>\n"),
- 'meta': "<meta http-equiv=\"content-type\" content=\"text/html; "+\
+ 'meta': "<meta http-equiv=\"content-type\" content=\"text/html; " + \
"charset=UTF-8\"/>\n",
'title': ("<title>", "</title>\n"),
'style': ("<style type=\"text/css\">\n<!--\n", "-->\n</style>\n"),
- 'style_svg': ("<style type=\"text/css\">\n<!--\n", "-->\n</style>\n"),
'body': ("<body>\n", "\n</body>\n"),
'div': ("<div>\n", "</div>\n"),
'slide': ("\n<a name=\"slide", "\"></a>\n"),
@@ -56,18 +49,24 @@ def save_html(self, tw, embed_flag=True):
'tr': ("<tr>\n", "</tr>\n"),
'td': ("<td valign=\"top\" width=\"400\" height=\"300\">\n",
"\n</td>\n"),
- 'img': ("<img width=\"400\" height=\"300\" alt=\"Image\" "+\
+ 'img': ("<img width=\"400\" height=\"300\" alt=\"Image\" " + \
"src=\"file://", ".png\" />\n"),
'img2': ("<img alt=\"Image\" src=\"image", ".png\" />\n"),
'img3': ("<img alt=\"Image\" src=\"file://", "\" />\n"),
'ul': ("<table>\n", "</table>\n"),
'li': ("<tr><td>", "</td></tr>\n") }
+ comment = "<!--\n\
+<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\" [\n\
+ <!ENTITY ns_svg \"http://www.w3.org/2000/svg\">\n\
+ <!ENTITY ns_xlink \"http://www.w3.org/1999/xlink\">\n\
+]>\n\
+-->\n"
if self.embed_images == True:
- self.html_glue['img'] = ("<img width=\"400\" height=\"300\" alt="+\
+ self.html_glue['img'] = ("<img width=\"400\" height=\"300\" alt="+ \
"\"Image\" src=\"data:image/png;base64,\n",
" \"/>\n")
- self.html_glue['img2'] = ("<img alt=\"Image\" src=\"data:image/png;"+\
+ self.html_glue['img2'] = ("<img alt=\"Image\" src=\"data:image/png;"+ \
"base64,\n", " \"/>\n")
"""
@@ -78,8 +77,8 @@ def save_html(self, tw, embed_flag=True):
if len(tw.saved_pictures) > 0:
for i, p in enumerate(tw.saved_pictures):
code += self.html_glue['slide'][0] + str(i)
- code += self.html_glue['slide'][1] +\
- self.html_glue['div'][0] +\
+ code += self.html_glue['slide'][1] + \
+ self.html_glue['div'][0] + \
self.html_glue['h1'][0]
if self.embed_images == True:
f = open(p, "r")
@@ -103,8 +102,8 @@ def save_html(self, tw, embed_flag=True):
tmp = self.html_glue['img3'][0]
tmp += p
tmp += self.html_glue['img3'][1]
- code += tmp +\
- self.html_glue['h1'][1] +\
+ code += tmp + \
+ self.html_glue['h1'][1] + \
self.html_glue['div'][1]
else:
if self.embed_images == True:
@@ -123,24 +122,25 @@ def save_html(self, tw, embed_flag=True):
else:
title = _("Turtle Art")
- header = self.html_glue['doctype'] +\
+ header = self.html_glue['doctype'] + \
self.html_glue['html'][0]
-
+ style = self.html_glue['style'][0] + \
+ self.html_glue['style'][1]
if len(tw.saved_pictures) > 0:
if tw.saved_pictures[0].endswith(('.svg')):
header = self.html_glue['html_svg'][0]
+ style = comment
- code = header +\
- self.html_glue['head'][0] +\
- self.html_glue['meta'] +\
- self.html_glue['title'][0] +\
- title +\
- self.html_glue['title'][1] +\
- self.html_glue['style'][0] +\
- self.html_glue['style'][1] +\
- self.html_glue['head'][1] +\
- self.html_glue['body'][0] +\
- code +\
- self.html_glue['body'][1] +\
+ code = header + \
+ self.html_glue['head'][0] + \
+ self.html_glue['meta'] + \
+ self.html_glue['title'][0] + \
+ title + \
+ self.html_glue['title'][1] + \
+ style + \
+ self.html_glue['head'][1] + \
+ self.html_glue['body'][0] + \
+ code + \
+ self.html_glue['body'][1] + \
self.html_glue['html'][1]
return code