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

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

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

revision 717 by jonathan, Wed Apr 23 08:45:44 2003 UTC revision 718 by jonathan, Wed Apr 23 10:39:46 2003 UTC
# Line 19  usrdir  = os.path.expanduser("~/.thuban" Line 19  usrdir  = os.path.expanduser("~/.thuban"
19  PROJ_EXT = ".proj"  PROJ_EXT = ".proj"
20    
21  def ReadProjFile(filename):  def ReadProjFile(filename):
22      """Read a single .proj file and return a ProjFile object."""      """Read a single .proj file and return a ProjFile object.
23        
24      projs = []      Raises IOError if the file cannot be opened.
25      try:      Raises OSError if the file cannot be read.
26          handler = ProjFileReader()      Raises SAXParseException if the file is not valid XML.
27          handler.read(filename)      """
         pf = handler.GetProjFile()  
     except OSError:  
         pass  
28    
29      return pf      handler = ProjFileReader()
30        handler.read(filename)
31        return handler.GetProjFile()
32    
33  def WriteProjFile(pf):  def WriteProjFile(pf):
34      saver = ProjFileSaver(pf)      saver = ProjFileSaver(pf)
# Line 42  def GetProjFiles(dir): Line 41  def GetProjFiles(dir):
41    
42      list = []      list = []
43      try:      try:
44          for file in filter(lambda s: s.endswith(PROJ_EXT), os.listdir(dir)):          dirlist = os.listdir(dir)
             filename = os.path.join(dir, file)  
             list.append(ReadProjFile(filename))  
45      except OSError:      except OSError:
46          pass          pass # if we can't get a directory listing just return []
47        else:
48            for file in filter(lambda s: s.endswith(PROJ_EXT), dirlist):
49                try:
50                    filename = os.path.join(dir, file)
51                    list.append(ReadProjFile(filename))
52                except (OSError, IOError, SAXParseException):
53                    pass # just move onto the next file
54    
55      return list      return list
56    

Legend:
Removed from v.717  
changed lines
  Added in v.718

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26