Logo Search packages:      
Sourcecode: zope-filesystemsite version File versions

def zope-filesystemsite-1.3::FSPropertiesObject::FSPropertiesObject::_readFile (   self,
  reparse 
) [private]

Read the data from the filesystem.

Read the file (indicated by exandpath(self._filepath), and parse the
data if necessary.

Definition at line 84 of file FSPropertiesObject.py.

00084                                 :
        """Read the data from the filesystem.
        
        Read the file (indicated by exandpath(self._filepath), and parse the
        data if necessary.
        """

        fp = expandpath(self._filepath)

        file = open(fp, 'r')    # not 'rb', as this is a text file!
        try:
            lines = file.readlines()
        finally:
            file.close()

        map = []
        lino=0

        for line in lines:

            lino = lino + 1
            line = line.strip()

            if not line or line[0] == '#':
                continue

            try:
                propname, proptv = line.split(':',1)
                #XXX multi-line properties?
                proptype, propvstr = proptv.split( '=', 1 ) 
                propname = propname.strip()
                proptype = proptype.strip()
                propvstr = propvstr.strip()
                converter = get_converter( proptype, lambda x: x )
                propvalue = converter( propvstr )
                # Should be safe since we're loading from
                # the filesystem.
                setattr(self, propname, propvalue)
                map.append({'id':propname,
                            'type':proptype,
                            'mode':'',
                            'default_value':propvalue,
                            })
            except:
                raise ValueError, ( 'Error processing line %s of %s:\n%s'
                                  % (lino,fp,line) )
        self._properties = tuple(map)            

    if Globals.DevelopmentMode:


Generated by  Doxygen 1.6.0   Back to index