/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/Model/save.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/Model/save.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 919 by frank, Mon May 12 10:46:29 2003 UTC revision 920 by bh, Fri May 16 17:37:29 2003 UTC
# Line 13  Functions to save a session to a file Line 13  Functions to save a session to a file
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    
# Line 142  class XMLWriter: Line 137  class XMLWriter:
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    

Legend:
Removed from v.919  
changed lines
  Added in v.920

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26