degal/filesystem.py
changeset 118 60b126ff0b74
parent 117 a2e4562deaab
child 139 d3167c40e7b9
equal deleted inserted replaced
117:a2e4562deaab 118:60b126ff0b74
   223             # syscall
   223             # syscall
   224             return os.stat(self.path)
   224             return os.stat(self.path)
   225 
   225 
   226         except OSError, e :
   226         except OSError, e :
   227             # trap ENOENT for soft
   227             # trap ENOENT for soft
   228             if soft and e.errno == errno.ENOENT :
   228             if e.errno == errno.ENOENT :
   229                 return None
   229                 return None
   230 
   230 
   231             else :
   231             else :
   232                 raise
   232                 raise
   233 
   233 
   560         if encoding :
   560         if encoding :
   561             return codecs.open(self.path, mode, encoding, errors, bufsize)
   561             return codecs.open(self.path, mode, encoding, errors, bufsize)
   562 
   562 
   563         else :
   563         else :
   564             return open(self.path, mode, *(arg for arg in (bufsize, ) if arg is not None))
   564             return open(self.path, mode, *(arg for arg in (bufsize, ) if arg is not None))
       
   565     
       
   566     def open_read (self, *args, **kwargs) :
       
   567         """ Open for read using open('r') """
       
   568 
       
   569         return self.open('r', *args, **kwargs)
   565 
   570 
   566     def open_write (self, *args, **kwargs) :
   571     def open_write (self, *args, **kwargs) :
   567         """
   572         """ Open for write using open('w') """
   568             Open for write using open('w').
       
   569         """
       
   570 
   573 
   571         return self.open('w', *args, **kwargs)
   574         return self.open('w', *args, **kwargs)
   572 
   575 
   573     def copy_from (self, file) :
   576     def copy_from (self, file) :
   574         """
   577         """
   697         """
   700         """
   698             Construct the directory tree root at the given 'real' path, which must be a raw str
   701             Construct the directory tree root at the given 'real' path, which must be a raw str
   699         """
   702         """
   700 
   703 
   701         # abuse Node's concept of a "name" a bit
   704         # abuse Node's concept of a "name" a bit
   702         super(Root, self).__init__(None, fspath)
   705         super(Root, self).__init__(None, fspath, config=config)
   703         
       
   704         # store our config
       
   705         self.config = config
       
   706 
   706 
   707     def nodepath (self) :
   707     def nodepath (self) :
   708         """
   708         """
   709             Just return ourself
   709             Just return ourself
   710         """
   710         """