[config] fix #799884: do not attempt to load stuff with incorrect names which sit in cubes/
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 15 Apr 2010 18:54:13 +0200
changeset 5298 66b0987716f9
parent 5297 cc747dcef851
child 5302 dfd147de06b2
[config] fix #799884: do not attempt to load stuff with incorrect names which sit in cubes/
cwconfig.py
--- a/cwconfig.py	Thu Apr 15 18:47:37 2010 +0200
+++ b/cwconfig.py	Thu Apr 15 18:54:13 2010 +0200
@@ -385,16 +385,20 @@
 
     @classmethod
     def available_cubes(cls):
+        import re
         cubes = set()
         for directory in cls.cubes_search_path():
             if not exists(directory):
                 cls.error('unexistant directory in cubes search path: %s'
-                           % directory)
+                          % directory)
                 continue
             for cube in os.listdir(directory):
-                if cube in ('CVS', '.svn', 'shared', '.hg'):
+                if cube == 'shared':
                     continue
-                if isdir(join(directory, cube)):
+                if not re.match('[_A-Za-z][_A-Za-z0-9]*$', cube):
+                    continue # skip invalid python package name
+                cubedir = join(directory, cube)
+                if isdir(cubedir) and exists(join(cubedir, '__init__.py')):
                     cubes.add(cube)
         return sorted(cubes)