[Python-checkins] cpython: fixed the separator issues in packaging/resources+config
tarek.ziade
python-checkins at python.org
Sat May 21 11:48:25 CEST 2011
http://hg.python.org/cpython/rev/b8f375e54516
changeset: 70242:b8f375e54516
user: Tarek Ziade <tarek at ziade.org>
date: Sat May 21 11:48:16 2011 +0200
summary:
fixed the separator issues in packaging/resources+config
files:
Lib/packaging/config.py | 6 +++++-
Lib/packaging/tests/test_resources.py | 1 -
Lib/packaging/util.py | 4 +++-
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/Lib/packaging/config.py b/Lib/packaging/config.py
--- a/Lib/packaging/config.py
+++ b/Lib/packaging/config.py
@@ -33,6 +33,9 @@
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 @@
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
diff --git a/Lib/packaging/tests/test_resources.py b/Lib/packaging/tests/test_resources.py
--- a/Lib/packaging/tests/test_resources.py
+++ b/Lib/packaging/tests/test_resources.py
@@ -25,7 +25,6 @@
files = {}
for path, value in spec.items():
if value is not None:
- path = self.os_dependent_path(path)
files[path] = value
return files
diff --git a/Lib/packaging/util.py b/Lib/packaging/util.py
--- a/Lib/packaging/util.py
+++ b/Lib/packaging/util.py
@@ -939,7 +939,7 @@
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 @@
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)):
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list