From 5c24d7b38311c2a46db2b9f9f221bd58a0e6401b Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Sat, 23 Jun 2012 15:16:24 +0000 Subject: remove unreliable code --- (limited to 'TurtleArt/taexporthtml.py') diff --git a/TurtleArt/taexporthtml.py b/TurtleArt/taexporthtml.py deleted file mode 100644 index 0e6a2f1..0000000 --- a/TurtleArt/taexporthtml.py +++ /dev/null @@ -1,161 +0,0 @@ -#Copyright (c) 2008-9, Walter Bender - -#Permission is hereby granted, free of charge, to any person obtaining a copy -#of this software and associated documentation files (the "Software"), to deal -#in the Software without restriction, including without limitation the rights -#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -#copies of the Software, and to permit persons to whom the Software is -#furnished to do so, subject to the following conditions: - -#The above copyright notice and this permission notice shall be included in -#all copies or substantial portions of the Software. - -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -#THE SOFTWARE. - -import pygtk -pygtk.require('2.0') -import gtk -import os.path -from cgi import escape -from gettext import gettext as _ - -from tautils import data_to_string, save_picture, image_to_base64, get_path - -# A dictionary to define the HTML wrappers around template elements -HTML_GLUE = { - 'doctype': '\n', - 'html': ('\n', '\n'), - 'html_svg': ('\n', - '\n'), - 'head': ('\n\n', '\n'), - 'meta': '\n', - 'title': ('', '\n'), - 'style': ('\n'), - 'body': ('\n', '\n\n'), - 'div': ('
\n', '
\n'), - 'slide': ('\n\n'), - 'h1': ('

', '

\n'), - 'table': ('\n', - '\n\n'), - 'img': ('Image\n'), - 'img2': ('Image\n'), - 'img3': ('Image\n'), - 'ul': ('
\n', '
\n'), - 'li': ('', '\n')} - -COMMENT = '\n' - - -def save_html(self, tw, embed_flag=True): - """ Either save the canvas and code or pictures to HTML """ - - if embed_flag: - HTML_GLUE['img'] = (' + \
-                                 \n') - HTML_GLUE['img2'] = ('Image\n') - - """ - If there are saved_pictures, put them into a .html; otherwise, - save a screendump and the turtle project code. - """ - htmlcode = '' - if len(tw.saved_pictures) > 0: - # saved_picture list is a collection of tuples of either the - # image_file or the containing dsobject and an SVG flag - for i, (image, svg_flag) in enumerate(tw.saved_pictures): - htmlcode += HTML_GLUE['slide'][0] + str(i) - htmlcode += HTML_GLUE['slide'][1] + \ - HTML_GLUE['div'][0] + \ - HTML_GLUE['h1'][0] - if tw.running_sugar: - from sugar.datastore import datastore - dobject = datastore.get(image) # dsobject.object_id - image_file = dobject.file_path - else: - image_file = image - if embed_flag: - f = open(image_file, 'r') - imgdata = f.read() - f.close() - if svg_flag: - tmp = imgdata - else: - imgdata = image_to_base64( - image_file, get_path(tw.activity, 'instance')) - tmp = HTML_GLUE['img2'][0] - tmp += imgdata - tmp += HTML_GLUE['img2'][1] - else: - if svg_flag: - f = open(image_file, 'r') - imgdata = f.read() - f.close() - tmp = imgdata - else: - tmp = HTML_GLUE['img3'][0] - tmp += image_file - tmp += HTML_GLUE['img3'][1] - htmlcode += tmp + \ - HTML_GLUE['h1'][1] + \ - HTML_GLUE['div'][1] - else: - if embed_flag: - tmp_file = os.path.join(get_path(tw.activity, 'instance'), - 'tmpfile.png') - save_picture(self.tw.canvas, tmp_file) - imgdata = image_to_base64(tmp_file, - get_path(tw.activity, 'instance')) - else: - imgdata = os.path.join(self.tw.load_save_folder, 'image') - self.tw.save_as_image(imgdata) - htmlcode += (HTML_GLUE['img'][0] + imgdata + \ - HTML_GLUE['img'][1]) - htmlcode += HTML_GLUE['div'][0] - htmlcode += escape(data_to_string( - tw.assemble_data_to_save(False, True))) - htmlcode += HTML_GLUE['div'][1] - - if tw.running_sugar: - title = _('Turtle Art') + ' ' + tw.activity.metadata['title'] - else: - title = _('Turtle Art') - - header = HTML_GLUE['doctype'] + \ - HTML_GLUE['html'][0] - style = HTML_GLUE['style'][0] + \ - HTML_GLUE['style'][1] - if len(tw.saved_pictures) > 0: - if tw.saved_pictures[0][1]: - header = HTML_GLUE['html_svg'][0] - style = COMMENT - - return header + \ - HTML_GLUE['head'][0] + \ - HTML_GLUE['meta'] + \ - HTML_GLUE['title'][0] + \ - title + \ - HTML_GLUE['title'][1] + \ - style + \ - HTML_GLUE['head'][1] + \ - HTML_GLUE['body'][0] + \ - htmlcode + \ - HTML_GLUE['body'][1] + \ - HTML_GLUE['html'][1] -- cgit v0.9.1