13 |
|
|
14 |
__version__ = "$Revision$" |
__version__ = "$Revision$" |
15 |
|
|
|
# fix for people using python2.1 |
|
|
from __future__ import nested_scopes |
|
|
|
|
16 |
import os |
import os |
17 |
import string |
import string |
18 |
|
|
19 |
import Thuban.Lib.fileutil |
import Thuban.Lib.fileutil |
20 |
|
|
|
from Thuban.Model.color import Color |
|
|
|
|
21 |
from Thuban.Model.classification import \ |
from Thuban.Model.classification import \ |
22 |
ClassGroupDefault, ClassGroupSingleton, ClassGroupRange, ClassGroupMap |
ClassGroupDefault, ClassGroupSingleton, ClassGroupRange, ClassGroupMap |
23 |
|
|
137 |
for name, value in attrs.items(): |
for name, value in attrs.items(): |
138 |
self.file.write(' %s="%s"' % (self.encode(name), |
self.file.write(' %s="%s"' % (self.encode(name), |
139 |
self.encode(value))) |
self.encode(value))) |
140 |
|
|
141 |
def encode(self, str): |
def encode(self, str): |
142 |
"""Assume that str is in Latin1, escape it, and encode it in UTF-8. |
"""Return an XML-escaped and UTF-8 encoded copy of the string str. |
143 |
|
|
144 |
If str is None, return None |
Assume that the argument is a bytestring in Latin 1. |
145 |
""" |
""" |
146 |
|
return unicode(escape(str),'latin1').encode("utf8") |
147 |
|
|
|
if str is not None: |
|
|
return unicode(escape(str),'latin1').encode("utf8") |
|
|
else: |
|
|
return None |
|
148 |
|
|
149 |
class SessionSaver(XMLWriter): |
class SessionSaver(XMLWriter): |
150 |
|
|