]> granicus.if.org Git - python/commitdiff
fixed the separator issues in packaging/resources+config
authorTarek Ziade <tarek@ziade.org>
Sat, 21 May 2011 09:48:16 +0000 (11:48 +0200)
committerTarek Ziade <tarek@ziade.org>
Sat, 21 May 2011 09:48:16 +0000 (11:48 +0200)
Lib/packaging/config.py
Lib/packaging/tests/test_resources.py
Lib/packaging/util.py

index 9875f6881c95f740081109cd37dfbf13c26ce6ea..6bbfdc30e9c91636c047ab00d57657931f20cd6c 100644 (file)
@@ -33,6 +33,9 @@ def _pop_values(values_dct, key):
 
 
 def _rel_path(base, path):
+    # normalizes and returns a lstripped-/-separated path
+    base = base.replace(os.path.sep, '/')
+    path = path.replace(os.path.sep, '/')
     assert path.startswith(base)
     return path[len(base):].lstrip('/')
 
@@ -50,7 +53,8 @@ def get_resources_dests(resources_root, rules):
                     destinations.pop(resource_file, None)
                 else:
                     rel_path = _rel_path(abs_base, abs_path)
-                    destinations[resource_file] = os.path.join(dest, rel_path)
+                    rel_dest = dest.replace(os.path.sep, '/').rstrip('/')
+                    destinations[resource_file] = rel_dest + '/' + rel_path
     return destinations
 
 
index 68450cdf6fb43970b198729677e9732d173cf9ab..1e92f2a8f25351cedf9cf8bb1ba43f9aff65933f 100644 (file)
@@ -25,7 +25,6 @@ class DataFilesTestCase(GlobTestCaseBase):
         files = {}
         for path, value in spec.items():
             if value is not None:
-                path = self.os_dependent_path(path)
                 files[path] = value
         return files
 
index bf31c31be6201e1b61c3be3e84399fda5e7c57b3..15da9e66a85c2ec64907a21c60ecf69146999401 100644 (file)
@@ -939,7 +939,7 @@ class Mixin2to3:
                         self.options, self.explicit)
 
 RICH_GLOB = re.compile(r'\{([^}]*)\}')
-_CHECK_RECURSIVE_GLOB = re.compile(r'[^/,{]\*\*|\*\*[^/,}]')
+_CHECK_RECURSIVE_GLOB = re.compile(r'[^/\\,{]\*\*|\*\*[^/\\,}]')
 _CHECK_MISMATCH_SET = re.compile(r'^[^{]*\}|\{[^}]*$')
 
 
@@ -973,7 +973,9 @@ def _iglob(path_glob):
             if radical == '':
                 radical = '*'
             else:
+                # we support both
                 radical = radical.lstrip('/')
+                radical = radical.lstrip('\\')
             for path, dir, files in os.walk(prefix):
                 path = os.path.normpath(path)
                 for file in _iglob(os.path.join(path, radical)):