2007-02-21 Zsolt Foldvari <zfoldvar@users.sourceforge.net>

* src/MarkupText.py: raise error in case of parsing failure.
	* src/const.py.in: add argument support for debug switch.
	* src/ArgHandler.py (parse_arg): handle debug switch argument.



svn: r8207
This commit is contained in:
Zsolt Foldvari 2007-02-21 16:20:55 +00:00
parent 2ce4226efb
commit bccf5acf4c
4 changed files with 23 additions and 16 deletions

View File

@ -1,3 +1,8 @@
2007-02-21 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
* src/MarkupText.py: raise error in case of parsing failure.
* src/const.py.in: add argument support for debug switch.
* src/ArgHandler.py (parse_arg): handle debug switch argument.
2007-02-20 Alex Roitman <shura@gramps-project.org>
* data/grampsxml.dtd: Update DTD.
* data/grampsxml.rng: Update schema.

View File

@ -256,7 +256,7 @@ class ArgHandler:
options_str = options[opt_ix+1][1]
self.actions.append((action,options_str))
elif o in ('-d', '--debug'):
l = logging.getLogger()
l = logging.getLogger(v)
l.setLevel(logging.DEBUG)
#-------------------------------------------------------------------------

View File

@ -253,7 +253,8 @@ class MarkupBuffer(gtk.TextBuffer):
It implements MarkupParser and MarkupWriter on the input/output interface.
Also translates Gramps XML markup language to gtk.TextTag's and vice versa.
Based on 'gourmet-0.13.3', http://grecipe-manager.sourceforge.net/
Based on 'gourmet-0.13.3' L{http://grecipe-manager.sourceforge.net}
Pango markup format is replaces by custom Gramps XML format.
"""
texttag_to_xml = {
@ -276,7 +277,7 @@ class MarkupBuffer(gtk.TextBuffer):
gtk.TextBuffer.__init__(self)
def set_text(self, xmltext):
"""Set the content of the buffer with markup tags"""
"""Set the content of the buffer with markup tags."""
try:
parseString(xmltext, self.parser)
text = self.parser.content
@ -303,7 +304,7 @@ class MarkupBuffer(gtk.TextBuffer):
self.apply_tag(tag, start_iter, end_iter)
def get_tag_from_element(self, name):
"""Convert xml element to gtk.TextTag"""
"""Convert xml element to gtk.TextTag."""
if not self.xml_to_texttag.has_key(name):
return None
@ -431,7 +432,8 @@ class EditorBuffer(MarkupBuffer):
normal_button is a widget whose clicked signal will make us normal
toggle_widget_alist is a list that looks like this: [(widget, tag_name),]
Based on 'gourmet-0.13.3', http://grecipe-manager.sourceforge.net/
Based on 'gourmet-0.13.3' L{http://grecipe-manager.sourceforge.net}
Pango markup format is replaces by custom Gramps XML format.
"""
__gtype_name__ = 'EditorBuffer'
@ -502,14 +504,14 @@ class EditorBuffer(MarkupBuffer):
try:
parseString("<gramps>%s</gramps>" % xmlstring, self.parser)
except:
# raise Error
log.debug("set: " % self.parser.content)
log.error('"%s" is not a valid Gramps XML format.' % xmlstring)
(start, end), name, attrs = self.parser.elements[0]
return self.setup_widget(widg, name)
def setup_widget(self, widg, name):
"""Setup widget from Gramps tag name."""
tag = self.get_tag_from_element(name)
self.tag_widgets[tag] = widg
return widg.connect('toggled', self._toggle, tag)

View File

@ -182,13 +182,13 @@ xmlFile = "data.gramps"
# (longName, shortName, type , default, flags, descrip , argDescrip)
popt_table = [
("open", 'O', str, None, 0, "Open file", "FILENAME"),
("import", 'i', str, None, 0, "Import file", "FILENAME"),
("output", 'o', str, None, 0, "Write file", "FILENAME"),
("format", 'f', str, None, 0, 'Specify format', "FORMAT"),
("action", 'a', str, None, 0, 'Specify action', "ACTION"),
("options", 'p', str, None, 0, 'Specify options', "OPTIONS_STRING"),
("debug", 'd', None, None, 0, 'Enable debug logs', ""),
("open", 'O', str, None, 0, "Open file", "FILENAME"),
("import", 'i', str, None, 0, "Import file", "FILENAME"),
("output", 'o', str, None, 0, "Write file", "FILENAME"),
("format", 'f', str, None, 0, 'Specify format', "FORMAT"),
("action", 'a', str, None, 0, 'Specify action', "ACTION"),
("options", 'p', str, None, 0, 'Specify options', "OPTIONS_STRING"),
("debug", 'd', str, None, 0, 'Enable debug logs', "LOGGER_NAME"),
]
longopts = [
@ -226,8 +226,8 @@ longopts = [
"format=",
"action=",
"options=",
"debug",
"debug=",
]
shortopts = "O:i:o:f:a:p:d?"
shortopts = "O:i:o:f:a:p:d:?"