[Python-checkins] distutils2: simplify expand function by remove the "destination" argument.
tarek.ziade
python-checkins at python.org
Wed Feb 16 22:23:58 CET 2011
tarek.ziade pushed 9e136b0d0eea to distutils2:
http://hg.python.org/distutils2/rev/9e136b0d0eea
changeset: 1084:9e136b0d0eea
user: Pierre-Yves David <pierre-yves.david at ens-lyon.org>
date: Sat Feb 05 17:14:32 2011 +0100
summary:
simplify expand function by remove the "destination" argument.
files:
distutils2/resources.py
diff --git a/distutils2/resources.py b/distutils2/resources.py
--- a/distutils2/resources.py
+++ b/distutils2/resources.py
@@ -3,13 +3,12 @@
__all__ = ['resources_dests']
-def _expand(root_dir, glob_base, glob_suffix, destination):
- """search for file in a directory and return they expected destination.
+def _expand(root_dir, glob_base, glob_suffix):
+ """search for file in a directory and return they radical part.
root_dir: directory where to search for resources.
- glob_base: part of the path not included in destination.
- glob_suffix: part of the path reused in the destination.
- destination: base part of the destination.
+ glob_base: part of the path not included in radical.
+ glob_suffix: part of the path used as radical.
"""
if glob_base:
base = os.path.join(root_dir, glob_base)
@@ -22,22 +21,15 @@
for glob_file in iglob(absglob):
path_suffix = glob_file[len(base):].lstrip('/')
relpath = glob_file[len(root_dir):].lstrip('/')
- dest = os.path.join(destination, path_suffix)
- yield relpath, dest
+ yield relpath, path_suffix
def resources_dests(resources_dir, rules):
"""find destination of ressources files"""
destinations = {}
for (base, suffix, glob_dest) in rules:
- if glob_dest is None:
- delete = True
- dest = ''
- else:
- delete = False
- dest = glob_dest
- for resource_file, file_dest in _expand(resources_dir, base, suffix, dest):
- if delete and resource_file in destinations:
- del destinations[resource_file]
+ for resource_file, radical in _expand(resources_dir, base, suffix):
+ if glob_dest is None:
+ destinations.pop(resource_file, None) #remove the entry if it was here
else:
- destinations[resource_file] = file_dest
+ destinations[resource_file] = os.path.join(glob_dest, radical)
return destinations
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list