From be56f74f93e97118dca32d83697803e3f9f42db0 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sun, 2 Jan 2011 01:32:17 +0000 Subject: [PATCH] Fixed #14998 -- Made use of os.path.join to make sure this works on all platforms. Thanks for the pointer, CarlFK. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15128 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- .../staticfiles/management/commands/collectstatic.py | 2 +- django/contrib/staticfiles/storage.py | 2 +- django/contrib/staticfiles/utils.py | 11 +++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/django/contrib/staticfiles/management/commands/collectstatic.py b/django/contrib/staticfiles/management/commands/collectstatic.py index 8882ae20db..10f9fdd016 100644 --- a/django/contrib/staticfiles/management/commands/collectstatic.py +++ b/django/contrib/staticfiles/management/commands/collectstatic.py @@ -100,7 +100,7 @@ Type 'yes' to continue, or 'no' to cancel: """) except (OSError, NotImplementedError): source_last_modified = None if prefix: - destination = '/'.join([prefix, source]) + destination = os.path.join(prefix, source) else: destination = source symlink = options['link'] diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py index eb0eabf861..56e5c0dec0 100644 --- a/django/contrib/staticfiles/storage.py +++ b/django/contrib/staticfiles/storage.py @@ -82,6 +82,6 @@ class AppStaticStorage(FileSystemStorage): prefix = self.get_prefix() for path in utils.get_files(self, ignore_patterns): if prefix: - path = '/'.join([prefix, path]) + path = os.path.join(prefix, path) files.append(path) return files diff --git a/django/contrib/staticfiles/utils.py b/django/contrib/staticfiles/utils.py index 428bb69b1e..187a6d3429 100644 --- a/django/contrib/staticfiles/utils.py +++ b/django/contrib/staticfiles/utils.py @@ -1,18 +1,17 @@ +import os import fnmatch from django.conf import settings from django.core.exceptions import ImproperlyConfigured def get_files(storage, ignore_patterns=[], location=''): """ - Recursively walk the storage directories gathering a complete list of files - that should be copied, returning this list. - + Recursively walk the storage directories gathering a complete + list of files that should be copied, returning this list. """ def is_ignored(path): """ Return True or False depending on whether the ``path`` should be ignored (if it matches any pattern in ``ignore_patterns``). - """ for pattern in ignore_patterns: if fnmatch.fnmatchcase(path, pattern): @@ -20,14 +19,14 @@ def get_files(storage, ignore_patterns=[], location=''): return False directories, files = storage.listdir(location) - static_files = [location and '/'.join([location, fn]) or fn + static_files = [location and os.path.join(location, fn) or fn for fn in files if not is_ignored(fn)] for dir in directories: if is_ignored(dir): continue if location: - dir = '/'.join([location, dir]) + dir = os.path.join(location, dir) static_files.extend(get_files(storage, ignore_patterns, dir)) return static_files