foiegras r55 - trunk/src/foiegras/buffer
- From: blsemage svn gnome org
- To: svn-commits-list gnome org
- Subject: foiegras r55 - trunk/src/foiegras/buffer
- Date: Tue, 19 Feb 2008 14:54:18 +0000 (GMT)
Author: blsemage
Date: Tue Feb 19 14:54:18 2008
New Revision: 55
URL: http://svn.gnome.org/viewvc/foiegras?rev=55&view=rev
Log:
2008-02-19 Buddhika Laknath <blaknath gmail com>
* Removed depricated files from old buffer (textview.py,buffer.py,inline_handler.py,editor.py)
* Derived block tags handling to a new block_handler.py
* Moved the new buffer inside buffer/
Added:
trunk/src/foiegras/buffer/docbuffer.py
Removed:
trunk/src/foiegras/buffer/buffer.py
trunk/src/foiegras/buffer/editor.py
trunk/src/foiegras/buffer/inline_handler.py
trunk/src/foiegras/buffer/testing.xml
trunk/src/foiegras/buffer/textview.py
Modified:
trunk/src/foiegras/buffer/attribute_handler.py
trunk/src/foiegras/buffer/attribute_renderer.py
trunk/src/foiegras/buffer/block_handler.py
trunk/src/foiegras/buffer/table.py
trunk/src/foiegras/buffer/table_handler.py
trunk/src/foiegras/buffer/tagparser.py
trunk/src/foiegras/buffer/xmlparser.py
Modified: trunk/src/foiegras/buffer/attribute_handler.py
==============================================================================
--- trunk/src/foiegras/buffer/attribute_handler.py (original)
+++ trunk/src/foiegras/buffer/attribute_handler.py Tue Feb 19 14:54:18 2008
@@ -1,5 +1,18 @@
-#!/usr/bin/env python
-#Gome doc project - Mallard - FoieGras
+# Copyright (C) 2007 by Buddhika Laknath <blaknath gmail com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
attribute_handler:
Modified: trunk/src/foiegras/buffer/attribute_renderer.py
==============================================================================
--- trunk/src/foiegras/buffer/attribute_renderer.py (original)
+++ trunk/src/foiegras/buffer/attribute_renderer.py Tue Feb 19 14:54:18 2008
@@ -1,5 +1,18 @@
-#!/usr/bin/env python
-#Gome doc project - Mallard - FoieGras
+# Copyright (C) 2007 by Buddhika Laknath <blaknath gmail com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
attribute_renderer:
Render the attributes.
Modified: trunk/src/foiegras/buffer/block_handler.py
==============================================================================
--- trunk/src/foiegras/buffer/block_handler.py (original)
+++ trunk/src/foiegras/buffer/block_handler.py Tue Feb 19 14:54:18 2008
@@ -1,110 +1,56 @@
-#!/usr/bin/env python
-#Gome doc project - Mallard - FoieGras
-
+# Copyright (C) 2007 by Buddhika Laknath <blaknath gmail com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import pygtk
pygtk.require('2.0')
import gtk
-import textview
+import docbuffer
-def handler(parser,element,attrs,tag_start,tag = None):
+def block_handler(buffer, tag_name, block_iter = None):
"""
Hanlder for block tags.
- controles how each block tag should render. Should be called from xmlparser
+ Maintains the working of nested block tags
+
+ If some text is selected, a block will be created from selected
+ text. If not, the text starting from current cursor point will
+ turn to a block.
"""
- #on tag start signal from xmlparser
- if tag_start is True:
- # parent is the main text view
- parent = parser.main_buffer.main_textview
-
- # temp_buffer is the current buffer
- parser.temp_buffer = gtk.TextBuffer( parser.main_buffer.get_tag_table() )
-
- # child is the new inner text view
- child = textview.MallardTextView(parser.temp_buffer)
- child.set_wrap_mode(gtk.WRAP_CHAR)
- child.show()
-
- # if no itme in innder_textviews list parent = main_buffer
- # else choose the innermost buffer from innder_textviews list
- if parser.main_buffer.inner_textviews:
- parent = parser.main_buffer.inner_textviews[len(parser.main_buffer.inner_textviews)-1]
-
- # if parent is a block container
- # add the previous block's height to get the total heigh
- if parent.is_block_container:
- parent.block_tag_length = parser.temp_block_height
- parser.temp_block_height = 0
-
- # the parent tag is a block container
- parent.is_block_container = True
-
- # if width and height is defined in the tag, request a set_size
- if "width" and "height" in parser.main_buffer.tag_details[element].keys():
- width = parser.main_buffer.tag_details[element]["width"]
- height = parser.main_buffer.tag_details[element]["height"]
- child.set_size_request(int(width),int(height))
-
- # if background is defined in the tag
- if "background" in parser.main_buffer.tag_details[element].keys():
- try:
- color = parser.main_buffer.tag_details[element]["background"]
- child.modify_base(gtk.STATE_NORMAL,gtk.gdk.color_parse(color) )
- except Exception:
- print "Color is not recognizable"
- exit()
-
- # get the text iter to position a new textview
- iter = parent.get_buffer().get_end_iter()
- anchor = parent.get_buffer().create_child_anchor(iter)
-
- # if a border is defined use a frame
- if parser.main_buffer.tag_details[element]["border"] != 0:
- frame = gtk.Frame()
- frame.add(child)
- parent.add_child_at_anchor(frame, anchor)
- frame.set_property('border-width', int(parser.main_buffer.tag_details[element]["border"]) )
- frame.set_property('shadow-type', gtk.SHADOW_ETCHED_IN)
- frame.set_property('shadow-type', gtk.SHADOW_ETCHED_IN)
- frame.show()
- else:
- parent.add_child_at_anchor(child,anchor)
-
- # add the new inner textview to the list
- parser.main_buffer.inner_textviews.insert(len(parser.main_buffer.inner_textviews),child)
-
- # retreive the text iter of current focused text view
- iter1 = parser.temp_buffer.get_end_iter()
-
- # shows the tag if show_tags is true
- if parser.show_tags:
- parser.temp_buffer.insert_with_tags_by_name(iter1,"\n<"+tag+">\n", parser.main_buffer.tag_details["mal_tag"]["tag"] )
- else:
- parser.temp_buffer.insert_with_tags_by_name(iter1,"\n" )
+
+ if not block_iter:
+ block_mark = buffer.get_insert()
+ block_iter = buffer.get_iter_at_mark(block_mark)
- # on tag end signal from xmlparser
+ if not block_iter.starts_line():
+ buffer.insert(block_iter,"\n")
+ block_iter = buffer.get_iter_at_mark(buffer.get_insert())
+
+ start_offset = block_iter.get_offset()
+
+ end_iter = buffer.get_iter_at_mark(buffer.get_selection_bound())
+ end_offset = end_iter.get_offset()
+
+ if not buffer.get_has_selection():
+ end_iter.forward_to_line_end()
+ end_offset = end_iter.get_offset()
else:
- iter1 = parser.temp_buffer.get_end_iter()
-
- # show the tag if show_tags is true
- if parser.show_tags:
- parser.temp_buffer.insert_with_tags_by_name(iter1,"\n</"+element+">\n", parser.main_buffer.tag_details["mal_tag"]["tag"] )
- elif parser.show_tags is False:
- parser.temp_buffer.insert_with_tags_by_name(iter1,"\n" )
-
- # change the focus to an outer textview
- if parser.main_buffer.inner_textviews:
- previous_textview = parser.main_buffer.inner_textviews.pop()
-
- if previous_textview.is_block_container == False:
- parser.temp_block_height = 0
-
- start,end = previous_textview.get_buffer().get_bounds()
- previous_textview.height += end.get_line()*20 + parser.temp_block_height + previous_textview.block_tag_length
- previous_textview.set_size_request(800,previous_textview.height )
- parser.temp_block_height += previous_textview.height
- #rect = previous_textview.get_visible_rect()
- #print parser.temp_block_height,element,previous_textview.block_tag_length
- if parser.main_buffer.inner_textviews:
- parser.temp_buffer = parser.main_buffer.inner_textviews[len(parser.main_buffer.inner_textviews)-1].get_buffer()
- else:
- parser.temp_buffer = parser.main_buffer
+ end_offset = end_offset+1
+ buffer.insert(end_iter,"\n")
+
+ start_iter = buffer.get_iter_at_offset(start_offset)
+ end_iter = buffer.get_iter_at_offset(end_offset)
+
+ buffer.apply_tag_by_name(tag_name, start_iter, end_iter)
+
+
Added: trunk/src/foiegras/buffer/docbuffer.py
==============================================================================
--- (empty file)
+++ trunk/src/foiegras/buffer/docbuffer.py Tue Feb 19 14:54:18 2008
@@ -0,0 +1,398 @@
+# Copyright (C) 2008 by Denis Washington <denisw svn gnome org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import pygtk
+pygtk.require('2.0')
+import gtk
+import pango
+import gobject
+
+from block_handler import block_handler
+
+def _(string):
+ return string
+
+
+INLINE_TAGS = []
+BLOCK_TAGS = []
+ATTRIBUTES = []
+
+TAG_TABLE = gtk.TextTagTable()
+
+def setup_tags():
+
+ def block_tag(name):
+ BLOCK_TAGS.append(name)
+ return gtk.TextTag(name)
+
+ def inline_tag(name):
+ INLINE_TAGS.append(name)
+ return gtk.TextTag(name)
+
+ # read-only areas
+ tag = gtk.TextTag("_readonly")
+ tag.set_property("editable", False)
+ TAG_TABLE.add(tag)
+
+ # <app>
+ tag = inline_tag("app")
+ TAG_TABLE.add(tag)
+
+ # <caption>
+ tag = block_tag("caption")
+ TAG_TABLE.add(tag)
+
+ # <cmd>
+ tag = inline_tag("cmd")
+ tag.set_property("family", "monospace")
+ TAG_TABLE.add(tag)
+
+ # <code>
+ tag = inline_tag("code")
+ tag.set_property("family", "monospace")
+ TAG_TABLE.add(tag)
+
+ # <code-inline>
+ tag = inline_tag("code-inline")
+ tag.set_property("family", "monospace")
+ TAG_TABLE.add(tag)
+
+ # <cite>
+ tag = block_tag("cite")
+ tag.set_property("style", pango.STYLE_ITALIC)
+ TAG_TABLE.add(tag)
+
+ # <date>
+ tag = inline_tag("date")
+ tag.set_property("style", pango.STYLE_ITALIC)
+ TAG_TABLE.add(tag)
+
+ # <em>
+ tag = inline_tag("em")
+ tag.set_property("weight", pango.WEIGHT_BOLD)
+ TAG_TABLE.add(tag)
+
+ # <figure>
+ tag = block_tag("figure")
+ TAG_TABLE.add(tag)
+
+ # <file>
+ tag = inline_tag("file")
+ tag.set_property("style", pango.STYLE_ITALIC)
+ TAG_TABLE.add(tag)
+
+ # <gui>
+ tag = inline_tag("gui")
+ tag.set_property("style", pango.STYLE_ITALIC)
+ TAG_TABLE.add(tag)
+
+ # <input>
+ tag = inline_tag("input")
+ tag.set_property("family", "monospace")
+ TAG_TABLE.add(tag)
+
+ # <key>
+ tag = inline_tag("key")
+ tag.set_property("style", pango.STYLE_ITALIC)
+ TAG_TABLE.add(tag)
+
+ # <link>
+ tag = inline_tag("link")
+ tag.set_property("foreground", "#0000ff")
+ tag.set_property("underline", True)
+ TAG_TABLE.add(tag)
+
+ # <list>
+ tag = block_tag("list")
+ TAG_TABLE.add(tag)
+
+ # <note>
+ tag = block_tag("note")
+ tag.set_property("paragraph-background", "#f0f0f0")
+ tag.set_property("foreground", "#0000ee")
+ TAG_TABLE.add(tag)
+
+ # <output>
+ tag = inline_tag("output")
+ tag.set_property("family", "monospace")
+ TAG_TABLE.add(tag)
+
+ # <p>
+ tag = block_tag("p")
+ TAG_TABLE.add(tag)
+
+ # <screen>
+ tag = block_tag("screen")
+ TAG_TABLE.add(tag)
+
+ # <synopsis>
+ tag = block_tag("synopsis")
+ TAG_TABLE.add(tag)
+
+ # <sys>
+ tag = inline_tag("sys")
+ tag.set_property("family", "monospace")
+ TAG_TABLE.add(tag)
+
+ # <title>
+ tag = block_tag("title")
+ tag.set_property("scale", pango.SCALE_XX_LARGE)
+ tag.set_property("underline", True)
+ TAG_TABLE.add(tag)
+
+ # <var>
+ tag = inline_tag("var")
+ tag.set_property("style", pango.STYLE_ITALIC)
+ TAG_TABLE.add(tag)
+
+setup_tags()
+
+
+class DocumentBuffer (gtk.TextBuffer):
+ """
+ Represents a Mallard document.
+ """
+
+ def __init__(self, filename = None):
+ """
+ Creates a Document.
+ """
+ gtk.TextBuffer.__init__(self, TAG_TABLE)
+
+ self.__filename = filename
+ self.__block_tag = "p"
+ self.__activated_tags = set()
+ self.__deactivated_tags = set()
+
+ self.connect("insert-text", self.__insert_text_cb)
+ self.connect_after("insert-text", self.__insert_text_after_cb)
+
+ if filename:
+ # TODO: File loading
+ pass
+ else:
+ self.set_text(_("New Topic\nAdd the topic's content here."))
+
+ start_iter = self.get_start_iter()
+ self.apply_block_tag("title", start_iter)
+
+ newline_iter = self.get_start_iter().copy()
+
+ while not newline_iter.get_char() == "\n":
+ newline_iter.forward_char()
+
+
+ end_iter = newline_iter.copy()
+ end_iter.forward_char()
+
+ self.apply_tag(self.get_tag_table().lookup("_readonly"), newline_iter, end_iter)
+
+
+ def get_filename(self):
+ """
+ Returns the name of the file represented by the buffer.
+ """
+ return self.__filename
+
+
+ def save(self, filename = None):
+ """
+ Saves the document buffer's content. If no file name is given,
+ the document is saved at the location referred to by the the
+ return value of the buffer's get_filename() method.
+ """
+ if filename:
+ self.__filename = filename
+
+ foiegras.buffer.save.save_document(self)
+
+
+ def apply_block_tag(self, tag_name, block_iter = None):
+ """
+ Applies a block tag to the block in which the passed text iterator
+ is located. If no iterator is given, the tag is applied to the block
+ at the current cursor position.
+ """
+
+ block_handler(self, tag_name, block_iter)
+
+
+ def apply_inline_tag(self, tag_name, start_iter = None, end_iter = None):
+ """
+ Applies an inline tag to the passed range. If both iterators point at
+ the same spot in the buffer, the tag is "activated", meaning that
+ it is applied to subsequently inserted text until deactivated. If no
+ iterators are given, the tag is applied to the currently selected range
+ (or activated at the current cursor position).
+ """
+ if not start_iter:
+ start_iter = self.get_iter_at_mark(self.get_insert())
+ if not end_iter:
+ end_iter = self.get_iter_at_mark(self.get_selection_bound())
+
+ if start_iter.equal(end_iter):
+ self.__set_tag_active(tag_name, True)
+ else:
+ self.apply_tag_by_name(tag_name, start_iter, end_iter)
+
+
+ def remove_inline_tag(self, tag_name, start_iter = None, end_iter = None):
+ """
+ Removes an inline tag from the passed range. If both iterators point at
+ the same spot in the buffer, the tag is deactivated (see doc comment of
+ apply_inline_tag()). If no iterators are given, the tag is removed from
+ the currently selected range (or deactivated at the current cursor
+ position).
+ """
+ if not start_iter:
+ start_iter = self.get_iter_at_mark(self.get_insert())
+ if not end_iter:
+ end_iter = self.get_iter_at_mark(self.get_selection_bound())
+
+ if start_iter.equal(end_iter):
+ self.__set_tag_active(tag_name, False)
+ else:
+ self.remove_tag_by_name(tag_name, start_iter, end_iter)
+
+
+ def __set_tag_active(self, tag_name, active):
+ """
+ Manually activates or deactivates a tag. (See apply_inline_tag().)
+ """
+ if active:
+ self.__activated_tags.add(tag_name)
+
+ if tag_name in self.__deactivated_tags:
+ self.__deactivated_tags.remove(tag_name)
+
+ else:
+ self.__deactivated_tags.add(tag_name)
+
+ if tag_name in self.__activated_tags:
+ self.__activated_tags.remove(tag_name)
+
+
+ def get_tags_at_selected_range(self):
+ """
+ Returns the names of all tags applied to the currently selected
+ text range or, if nothing is selected, of the current cursor
+ position.
+ """
+ bounds = self.get_selection_bounds()
+
+ if len(bounds) == 0:
+ start = end = self.get_iter_at_mark(self.get_insert())
+ else:
+ start = bounds[0]
+ end = bounds[1]
+
+ start.backward_char()
+
+ tags = set()
+
+ for tag in start.get_tags():
+ tags.add(tag.get_property("name"))
+
+ if start.equal(end):
+ tags = tags.union(self.__activated_tags)
+ else:
+ it = start.copy()
+
+ while not it.equal(end):
+ applied = set()
+
+ for tag in it.get_tags():
+ applied.add(tag.get_property("name"))
+
+ tags = tags.intersection(applied)
+ it.forward_char()
+
+ if len(tags) == 0:
+ tags.add("p")
+
+ return tags
+
+
+ def __insert_text_cb(self, textbuffer, location, text, length):
+ """
+ "insert-text" signal handler.
+ """
+ block_tag = None
+
+ for tag_name in BLOCK_TAGS:
+ tag = self.get_tag_table().lookup(tag_name)
+
+ if location.has_tag(tag):
+ block_tag = tag_name
+
+ if block_tag:
+ self.__block_tag = block_tag
+ else:
+ self.__block_tag = "p"
+
+
+
+ def __insert_text_after_cb(self, textbuffer, location, text, length):
+ """
+ "insert-text" signal handler. (Runs after the default hander).
+ """
+ num_lines_back = 0
+
+ for i in range(length):
+ if text[i] == "\n" or (text[i] == "\r" and text[i + 1] != "\n"):
+ num_lines_back += 1
+
+ for i in range(num_lines_back):
+ location.backward_line()
+
+ #self.apply_block_tag(self.__block_tag, location)
+
+ start_iter = location.copy()
+ start_iter.backward_chars(length)
+
+ for tag_name in self.__get_active_tags(start_iter):
+ self.apply_tag_by_name(tag_name, start_iter, location)
+
+ self.notify("cursor-position")
+
+
+ def __get_active_tags(self, location):
+ """
+ Returns the active tags at the passed text iterator.
+ """
+ active_tags = set()
+
+ it = location.copy()
+ it.backward_char()
+
+ for tag in it.get_tags():
+ tag_name = tag.get_property("name")
+
+ if not tag_name.startswith("_") and \
+ not (it.ends_line() and tag_name in BLOCK_TAGS):
+ active_tags.add(tag.get_property("name"))
+
+ active_tags = active_tags.union(self.__activated_tags)
+ active_tags = active_tags.difference(self.__deactivated_tags)
+
+ self.__activated_tags.clear()
+ self.__deactivated_tags.clear()
+
+ if len(active_tags) == 0:
+ active_tags.add("p")
+
+ return active_tags
+
Modified: trunk/src/foiegras/buffer/table.py
==============================================================================
--- trunk/src/foiegras/buffer/table.py (original)
+++ trunk/src/foiegras/buffer/table.py Tue Feb 19 14:54:18 2008
@@ -1,5 +1,18 @@
-#!/usr/bin/env python
-#Gome doc project - Mallard - FoieGras
+# Copyright (C) 2007 by Buddhika Laknath <blaknath gmail com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import pygtk
pygtk.require('2.0')
Modified: trunk/src/foiegras/buffer/table_handler.py
==============================================================================
--- trunk/src/foiegras/buffer/table_handler.py (original)
+++ trunk/src/foiegras/buffer/table_handler.py Tue Feb 19 14:54:18 2008
@@ -1,9 +1,23 @@
-#!/usr/bin/env python
-#Gome doc project - Mallard - FoieGras
+# Copyright (C) 2007 by Buddhika Laknath <blaknath gmail com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import pygtk
pygtk.require('2.0')
-import gtk,textview
+import gtk
+
def handler(parser, element, attrs, tag_start, tag = None):
"""
Modified: trunk/src/foiegras/buffer/tagparser.py
==============================================================================
--- trunk/src/foiegras/buffer/tagparser.py (original)
+++ trunk/src/foiegras/buffer/tagparser.py Tue Feb 19 14:54:18 2008
@@ -1,3 +1,19 @@
+# Copyright (C) 2007 by Buddhika Laknath <blaknath gmail com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
import pygtk
pygtk.require('2.0')
import gtk,sys
Modified: trunk/src/foiegras/buffer/xmlparser.py
==============================================================================
--- trunk/src/foiegras/buffer/xmlparser.py (original)
+++ trunk/src/foiegras/buffer/xmlparser.py Tue Feb 19 14:54:18 2008
@@ -1,11 +1,24 @@
-#!/usr/bin/env python
-#Gome doc project - Mallard - FoieGras
+# Copyright (C) 2007 by Buddhika Laknath <blaknath gmail com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import pygtk
pygtk.require('2.0')
import gtk
import xml.parsers.expat
-import block_handler, inline_handler, table_handler, attribute_handler
+import block_handler, table_handler, attribute_handler
class Parser:
@@ -92,14 +105,14 @@
except KeyError, msg:
# occur in an invalid key exception
print "No such tag as", msg
- exit()
+ #exit()
except attribute_handler.InvlidAttribute, msg:
# occur in invalid value exception
print msg
- exit()
+ #exit()
except Exception, msg:
print "Error:", msg
- exit()
+ #exit()
# for unknown tags
else:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]