changeset a74f1ba1574a in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=a74f1ba1574a
description: Use the logging module instead wanings in htmlview.py
diffstat:
src/htmltextview.py | 48 +++++++++++++++++++-----------------------------
1 files changed, 19 insertions(+), 29 deletions(-)
diffs (178 lines):
diff -r ca2800ac665f -r a74f1ba1574a src/htmltextview.py
--- a/src/htmltextview.py Fri Nov 26 22:57:32 2010 +0300
+++ b/src/htmltextview.py Sat Nov 27 00:43:13 2010 +0300
@@ -40,7 +40,6 @@
import gtk
import xml.sax, xml.sax.handler
import re
-import warnings
from cStringIO import StringIO
import socket
import time
@@ -56,7 +55,8 @@
from common import gajim
import tooltips
-
+import logging
+log = logging.getLogger('gajim.htmlview')
__all__ = ['HtmlTextView']
@@ -302,7 +302,7 @@
val = sign*max(minl, min(abs(val), maxl))
callback(val, *args)
except Exception:
- warnings.warn('Unable to parse length value "%s"' % value)
+ log.warning('Unable to parse length value "%s"' % value)
def __parse_font_size_cb(length, tag):
tag.set_property('size-points', length/display_resolution)
@@ -348,7 +348,7 @@
'oblique': pango.STYLE_OBLIQUE,
} [value]
except KeyError:
- warnings.warn('unknown font-style %s' % value)
+ log.warning('unknown font-style %s' % value)
else:
tag.set_property('style', style)
@@ -386,7 +386,7 @@
'bold': pango.WEIGHT_BOLD,
} [value]
except KeyError:
- warnings.warn('unknown font-style %s' % value)
+ log.warning('unknown font-style %s' % value)
else:
tag.set_property('weight', weight)
@@ -402,7 +402,7 @@
'justify': gtk.JUSTIFY_FILL,
} [value]
except KeyError:
- warnings.warn('Invalid text-align:%s requested' % value)
+ log.warning('Invalid text-align:%s requested' % value)
else:
tag.set_property('justification', align)
@@ -420,9 +420,9 @@
else:
tag.set_property('strikethrough', False)
if 'blink' in values:
- warnings.warn('text-decoration:blink not implemented')
+ log.warning('text-decoration:blink not implemented')
if 'overline' in values:
- warnings.warn('text-decoration:overline not implemented')
+ log.warning('text-decoration:overline not implemented')
def _parse_style_white_space(self, tag, value):
if value == 'pre':
@@ -436,7 +436,7 @@
try:
tag.set_property(propname, value)
except Exception:
- gajim.log.warn( "Error with prop: " + propname + " for tag: " +
str(tag))
+ log.warning( "Error with prop: " + propname + " for tag: " +
str(tag))
def _parse_style_width(self, tag, value):
@@ -460,7 +460,7 @@
try:
method = locals()['_parse_style_%s' % style.replace('-', '_')]
except KeyError:
- warnings.warn('Style attribute "%s" not yet implemented' % style)
+ log.warning('Style attribute "%s" not yet implemented' % style)
else:
__style_methods[style] = method
del style
@@ -496,7 +496,7 @@
req.add_header('User-Agent', 'Gajim ' + gajim.version)
f = urllib2.urlopen(req)
except Exception, ex:
- gajim.log.debug('Error loading image %s ' % attrs['src'] +
str(ex))
+ log.debug('Error loading image %s ' % attrs['src'] + str(ex))
pixbuf = None
alt = attrs.get('alt', 'Broken image')
else:
@@ -509,7 +509,7 @@
deadline = time.time() + 3
while True:
if time.time() > deadline:
- gajim.log.debug(str('Timeout loading image %s ' % \
+ log.debug(str('Timeout loading image %s ' % \
attrs['src'] + ex))
mem = ''
alt = attrs.get('alt', '')
@@ -520,7 +520,7 @@
try:
temp = f.read(100)
except socket.timeout, ex:
- gajim.log.debug('Timeout loading image %s ' % \
+ log.debug('Timeout loading image %s ' % \
attrs['src'] + str(ex))
alt = attrs.get('alt', '')
if alt:
@@ -596,7 +596,7 @@
else:
self._insert_text('[IMG: %s]' % alt)
except Exception, ex:
- gajim.log.error('Error loading image ' + str(ex))
+ log.error('Error loading image ' + str(ex))
pixbuf = None
alt = attrs.get('alt', 'Broken image')
try:
@@ -620,7 +620,7 @@
try:
method = self.__style_methods[attr]
except KeyError:
- warnings.warn('Style attribute "%s" requested '
+ log.warning('Style attribute "%s" requested '
'but not yet implemented' % attr)
else:
method(self, tag, val)
@@ -755,7 +755,7 @@
elif name in INLINE:
self._jump_line()
else:
- warnings.warn('Unhandled element "%s"' % name)
+ log.warning('Unhandled element "%s"' % name)
def endElement(self, name):
endPreserving = False
@@ -771,7 +771,7 @@
#self._insert_text(u'\u2550'*40)
self._jump_line()
except Exception, e:
- gajim.log.debug(str('Error in hr'+e))
+ log.debug(str('Error in hr'+e))
elif name in LIST_ELEMS:
self.list_counters.pop()
elif name == 'li':
@@ -790,7 +790,7 @@
if name == 'pre':
endPreserving = True
else:
- warnings.warn("Unhandled element '%s'" % name)
+ log.warning("Unhandled element '%s'" % name)
self._flush_text()
if endPreserving:
self.preserve = False
@@ -935,17 +935,7 @@
from conversation_textview import ConversationTextview
import gajim as gaj
- class log(object):
-
- def debug(self, text):
- print "debug:", text
- def warn(self, text):
- print "warn;", text
- def error(self, text):
- print "error;", text
-
- gajim.log=log()
-
+ log = logging.getLogger()
gaj.Interface()
htmlview = ConversationTextview(None)
_______________________________________________
Commits mailing list
[email protected]
http://lists.gajim.org/cgi-bin/listinfo/commits