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

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

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

revision 473 by jonathan, Wed Mar 5 18:39:45 2003 UTC revision 614 by jonathan, Mon Apr 7 08:56:38 2003 UTC
# Line 17  import sys, string, os Line 17  import sys, string, os
17    
18  import xml.sax  import xml.sax
19  import xml.sax.handler  import xml.sax.handler
20  from xml.sax import make_parser, ErrorHandler  from xml.sax import make_parser, ErrorHandler, SAXNotRecognizedException
21    
22  from Thuban import _  from Thuban import _
23  from Thuban.common import *  from Thuban.common import *
# Line 43  def parse_color(color): Line 43  def parse_color(color):
43      """      """
44      color = string.strip(color)      color = string.strip(color)
45      if color == "None":      if color == "None":
46          result = Color.None          result = Color.Transparent
47      elif color[0] == '#':      elif color[0] == '#':
48          if len(color) == 7:          if len(color) == 7:
49              r = string.atoi(color[1:3], 16) / 255.0              r = string.atoi(color[1:3], 16) / 255.0
# Line 217  class ProcessSession(xml.sax.handler.Con Line 217  class ProcessSession(xml.sax.handler.Con
217    
218      def end_clpoint(self, name, qname):      def end_clpoint(self, name, qname):
219          self.cl_group.SetProperties(self.cl_prop)          self.cl_group.SetProperties(self.cl_prop)
220          self.aLayer.GetClassification().AddGroup(self.cl_group)          self.aLayer.GetClassification().AppendGroup(self.cl_group)
221          del self.cl_group, self.cl_prop          del self.cl_group, self.cl_prop
222      end_dispatcher['clpoint'] = "end_clpoint"      end_dispatcher['clpoint'] = "end_clpoint"
223    
# Line 239  class ProcessSession(xml.sax.handler.Con Line 239  class ProcessSession(xml.sax.handler.Con
239    
240      def end_clrange(self, name, qname):      def end_clrange(self, name, qname):
241          self.cl_group.SetProperties(self.cl_prop)          self.cl_group.SetProperties(self.cl_prop)
242          self.aLayer.GetClassification().AddGroup(self.cl_group)          self.aLayer.GetClassification().AppendGroup(self.cl_group)
243          del self.cl_group, self.cl_prop          del self.cl_group, self.cl_prop
244      end_dispatcher['clrange'] = "end_clrange"      end_dispatcher['clrange'] = "end_clrange"
245    
# Line 256  class ProcessSession(xml.sax.handler.Con Line 256  class ProcessSession(xml.sax.handler.Con
256      end_dispatcher['cldata'] = "end_cldata"      end_dispatcher['cldata'] = "end_cldata"
257    
258      def start_table(self, name, qname, attrs):      def start_table(self, name, qname, attrs):
259          print "table title: %s" % attrs.get('title', None)          #print "table title: %s" % attrs.get('title', None)
260            pass
261      start_dispatcher['table'] = "start_table"      start_dispatcher['table'] = "start_table"
262    
263      def end_table(self, name, qname):      def end_table(self, name, qname):
# Line 290  def load_session(filename): Line 291  def load_session(filename):
291      parser.setContentHandler(handler)      parser.setContentHandler(handler)
292      parser.setErrorHandler(ErrorHandler())      parser.setErrorHandler(ErrorHandler())
293      parser.setFeature(xml.sax.handler.feature_namespaces, 1)      parser.setFeature(xml.sax.handler.feature_namespaces, 1)
294    
295        #
296        # Well, this isn't pretty, but it appears that if you
297        # use Python 2.2 without the site-package _xmlplus then
298        # the following will fail, and without them it will work.
299        # However, if you do have the site-package and you don't
300        # call these functions, the reader raises an exception
301        #
302        # The reason we set these to 0 in the first place is
303        # because there is an unresolved issue with external
304        # entities causing an exception in the reader
305        #
306        try:
307            parser.setFeature(xml.sax.handler.feature_validation, 0)
308            parser.setFeature(xml.sax.handler.feature_external_ges, 0)
309            parser.setFeature(xml.sax.handler.feature_external_pes, 0)
310        except SAXNotRecognizedException:
311            pass
312    
313      parser.parse(file)      parser.parse(file)
314    
315      session = handler.theSession      session = handler.theSession

Legend:
Removed from v.473  
changed lines
  Added in v.614

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26