[CMF-checkins] CVS: CMF/CMFCore - FSMetadata.py:1.6

Sidnei da Silva sidnei@x3ng.com.br
Sat, 24 May 2003 10:37:55 -0400


Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv21522/CMFCore

Modified Files:
	FSMetadata.py 
Log Message:
Whitespace cleaning, plus report the filename upon exception

=== CMF/CMFCore/FSMetadata.py 1.5 => 1.6 ===
--- CMF/CMFCore/FSMetadata.py:1.5	Fri May 23 21:12:59 2003
+++ CMF/CMFCore/FSMetadata.py	Sat May 24 10:37:54 2003
@@ -11,7 +11,7 @@
 import re
 
 class CMFConfigParser(ConfigParser):
-    """ This our wrapper around ConfigParser to 
+    """ This our wrapper around ConfigParser to
     solve a few minor niggles with the code """
     # adding in a space so that names can contain spaces
     OPTCRE = re.compile(
@@ -21,11 +21,11 @@
                                               # (either : or =), followed
                                               # by any # space/tab
         r'(?P<value>.*)$'                     # everything up to eol
-        )    
+        )
 
     def optionxform(self, optionstr):
-        """ 
-        Stop converting the key to lower case, very annoying for security etc 
+        """
+        Stop converting the key to lower case, very annoying for security etc
         """
         return optionstr.strip()
 
@@ -67,7 +67,7 @@
         """ Read the new file format using ConfigParser """
         self._properties = {}
         self._security = {}
-        
+
         try:
             cfg = CMFConfigParser()
             cfg.read(self._filename + '.metadata')
@@ -80,45 +80,46 @@
                  ERROR,
                 'Error parsing .metadata file',
                  error=exc_info())
-        
+
         # to add in a new value such as proxy roles,
         # just add in the section, call it using getSectionDict
         # if you need a special parser for some whacky
         # config, then just pass through a special parser
-    
+
     def _nullParser(self, data):
-        """ 
-        This is the standard rather boring null parser that does very little 
+        """
+        This is the standard rather boring null parser that does very little
         """
         return data
-    
+
     def _securityParser(self, data):
-        """ A specific parser for security lines 
-        
+        """ A specific parser for security lines
+
         Security lines must be of the format
-        
+
         (0|1):Role[,Role...]
-        
+
         Where 0|1 is the acquire permission setting
         and Role is the roles for this permission
         eg: 1:Manager or 0:Manager,Anonymous
         """
-        if data.find(':') < 1: 
-            raise ValueError, "The security declaration is in the wrong format"
-            
+        if data.find(':') < 1:
+            raise ValueError, "The security declaration of file " + \
+                  "%r is in the wrong format" % self._filename
+
         acquire, roles = data.split(':')
         roles = [r.strip() for r in roles.split(',') if r.strip()]
         return (acquire, roles)
 
     def _getSectionDict(self, cfg, section, parser=None):
-        """ 
+        """
         Get a section and put it into a dict, mostly a convenience
         function around the ConfigParser
-        
+
         Note: the parser is a function to parse each value, so you can
-        have custom values for the key value pairs 
+        have custom values for the key value pairs
         """
-        if parser is None: 
+        if parser is None:
             parser = self._nullParser
 
         props = {}
@@ -134,7 +135,7 @@
     def _old_readProperties(self):
         """
         Reads the properties file next to an object.
-        
+
         Moved from DirectoryView.py to here with only minor
         modifications. Old and deprecated in favour of .metadata now
         """
@@ -158,11 +159,11 @@
                         error=exc_info())
 
             return props
-    
+
     def _old_readSecurity(self):
         """
         Reads the security file next to an object.
-        
+
         Moved from DirectoryView.py to here with only minor
         modifications. Old and deprecated in favour of .metadata now
         """
@@ -170,7 +171,7 @@
         try:
             f = open(fp, 'rt')
         except IOError:
-            return None        
+            return None
         else:
             lines = f.readlines()
             f.close()
@@ -180,7 +181,7 @@
                     c1 = line.index(':')+1
                     c2 = line.index(':',c1)
                     permission = line[:c1-1]
-                    acquire = not not line[c1:c2] # get boolean                    
+                    acquire = not not line[c1:c2] # get boolean
                     proles = line[c2+1:].split(',')
                     roles=[]
                     for role in proles: