__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.
base = os.path.join(root_dir, glob_base)
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, path_suffix
def resources_dests(resources_dir, rules):
"""find destination of ressources files"""
for (base, suffix, glob_dest) in rules:
- 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):
+ destinations.pop(resource_file, None) #remove the entry if it was here
- destinations[resource_file] =
+ destinations[resource_file] =