[Python-checkins] distutils2: Allow glob in base part of ressource files
tarek.ziade
python-checkins at python.org
Wed Feb 16 22:23:58 CET 2011
tarek.ziade pushed 495547cc414e to distutils2:
http://hg.python.org/distutils2/rev/495547cc414e
changeset: 1086:495547cc414e
user: Pierre-Yves David <pierre-yves.david at ens-lyon.org>
date: Sat Feb 05 17:44:01 2011 +0100
summary:
Allow glob in base part of ressource files
We should be carefull that conflicting rename are detected.
files:
distutils2/resources.py
distutils2/tests/test_resources.py
diff --git a/distutils2/resources.py b/distutils2/resources.py
--- a/distutils2/resources.py
+++ b/distutils2/resources.py
@@ -18,14 +18,12 @@
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"""
diff --git a/distutils2/tests/test_resources.py b/distutils2/tests/test_resources.py
--- a/distutils2/tests/test_resources.py
+++ b/distutils2/tests/test_resources.py
@@ -70,9 +70,10 @@
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}')]
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list