Commits

Pierre-Yves David  committed 495547c

Allow glob in base part of ressource files

We should be carefull that conflicting rename are detected.

  • Participants
  • Parent commits 57af7fe

Comments (0)

Files changed (2)

File distutils2/resources.py

         base = os.path.join(root_dir, glob_base)
     else:
         base = root_dir
-    if '*' in base or '{' in base or '}'  in base:
-        raise NotImplementedError('glob are not supported into base part\
-            of resources definition. %r is an invalide root_dir' % base)
-    absglob = os.path.join(base, glob_suffix)
-    for glob_file in iglob(absglob):
-        path_suffix = _rel_path(base, glob_file)
-        relpath = _rel_path(root_dir, glob_file)
-        yield relpath, path_suffix
+    for base_dir in iglob(base):
+        absglob = os.path.join(base_dir, glob_suffix)
+        for glob_file in iglob(absglob):
+            path_suffix = _rel_path(base_dir, glob_file)
+            relpath = _rel_path(root_dir, glob_file)
+            yield relpath, path_suffix
 
 def resources_dests(resources_dir, rules):
     """find destination of ressources files"""

File distutils2/tests/test_resources.py

     def test_glob_in_base(self):
         rules = [('scrip*', '*.bin', '{appscript}')]
         spec  = {'scripts/scripts.bin': '{appscript}/scripts.bin',
-            'Babarlikestrawberry': None}
-        tempdir = self.build_files_tree(spec)
-        self.assertRaises(NotImplementedError, resources_dests, tempdir, rules)
+                 'scripouille/babar.bin': '{appscript}/babar.bin',
+                 'scriptortu/lotus.bin': '{appscript}/lotus.bin',
+                 'Babarlikestrawberry': None}
+        self.assertRulesMatch(rules, spec)
 
     def test_recursive_glob(self):
         rules = [('', '**/*.bin', '{binary}')]