[rig3] r448 committed - IzuParser: fix accents conversion with unicode input....

1 view
Skip to first unread message

ri...@googlecode.com

unread,
Aug 30, 2010, 1:17:46 AM8/30/10
to rig3-d...@googlegroups.com
Revision: 448
Author: ralfoide
Date: Sun Aug 29 22:17:07 2010
Log: IzuParser: fix accents conversion with unicode input.
Source OldIzu Reader: fix filepath for tags parsing.
http://code.google.com/p/rig3/source/detail?r=448

Modified:
/trunk/rig3serv/src/rig/parser/izu_parser.py
/trunk/rig3serv/src/rig/source_reader.py
/trunk/rig3serv/src/rig/version.py

=======================================
--- /trunk/rig3serv/src/rig/parser/izu_parser.py Sun Aug 29 21:19:47 2010
+++ /trunk/rig3serv/src/rig/parser/izu_parser.py Sun Aug 29 22:17:07 2010
@@ -560,12 +560,18 @@
Converts accents to HTML encoding entities.
Returns the formatted line.
"""
+ is_unicode = isinstance(line, unicode)
for k, v in _ACCENTS_TO_HTML.iteritems():
+ if is_unicode:
+ # If line is of type unicode, k cannot be str, it must
+ # be converted to unicode using the encoding of
_ACCENTS_TO_HTML
+ # otherwise the "k in line" will fail with a type error.
+ k = unicode(k, "iso-8859-1")
if k in line:
line = line.replace(k, v)

try:
- if isinstance(line, unicode):
+ if is_unicode:
us = line
else:
us = line.decode("utf-8")
=======================================
--- /trunk/rig3serv/src/rig/source_reader.py Sun Aug 29 21:19:47 2010
+++ /trunk/rig3serv/src/rig/source_reader.py Sun Aug 29 22:17:07 2010
@@ -182,7 +182,6 @@
def _ParseOldIzu(self, rel_file, cat, items):
"""
"""
- f = file(rel_file.abs_path, "rU")

SEP = "----"

@@ -192,11 +191,11 @@
encoding = self._site_settings.encoding

# First line must have some izu tags
- tags = IzuParser(self._log, None, None).ParseFileFirstLine(f,
encoding)
+ tags = IzuParser(self._log, None,
None).ParseFileFirstLine(rel_file.abs_path, encoding)

# If we find an encoding tag, reparse the tags using that encoding
if "encoding" in tags:
- tags = IzuParser(self._log, None, None).ParseFileFirstLine(f,
encoding)
+ tags = IzuParser(self._log, None,
None).ParseFileFirstLine(rel_file.abs_path, encoding)

f = codecs.open(rel_file.abs_path, mode="rU", encoding=encoding)
# Skip to the first section
=======================================
--- /trunk/rig3serv/src/rig/version.py Sun Aug 29 21:19:47 2010
+++ /trunk/rig3serv/src/rig/version.py Sun Aug 29 22:17:07 2010
@@ -13,7 +13,7 @@
To enable substitutions, do something like this:
$ svn propset svn:keywords "Date Author Revision HeadURL Id" version.py

------
+----

Part of Rig3.
Copyright (C) 2007-2009 ralfoide gmail com

Reply all
Reply to author
Forward
0 new messages