Remove old python 2.5 compatibility functions as we are dropping 2.5 support
This commit is contained in:
@@ -29,7 +29,6 @@ from compressor.cache import get_offline_hexdigest, write_offline_manifest
|
||||
from compressor.conf import settings
|
||||
from compressor.exceptions import OfflineGenerationError
|
||||
from compressor.templatetags.compress import CompressorNode
|
||||
from compressor.utils import walk, any
|
||||
|
||||
|
||||
def patched_render(self, context):
|
||||
@@ -199,7 +198,7 @@ class Command(NoArgsCommand):
|
||||
log.write("Considering paths:\n\t" + "\n\t".join(paths) + "\n")
|
||||
templates = set()
|
||||
for path in paths:
|
||||
for root, dirs, files in walk(path,
|
||||
for root, dirs, files in os.walk(path,
|
||||
followlinks=options.get('followlinks', False)):
|
||||
templates.update(os.path.join(root, name)
|
||||
for name in files if not name.startswith('.') and
|
||||
|
@@ -6,7 +6,6 @@ from django.core.management.base import NoArgsCommand, CommandError
|
||||
|
||||
from compressor.conf import settings
|
||||
from compressor.cache import cache, get_mtime, get_mtime_cachekey
|
||||
from compressor.utils import walk
|
||||
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
@@ -58,7 +57,7 @@ class Command(NoArgsCommand):
|
||||
files_to_add = set()
|
||||
keys_to_delete = set()
|
||||
|
||||
for root, dirs, files in walk(settings.COMPRESS_ROOT, followlinks=options['follow_links']):
|
||||
for root, dirs, files in os.walk(settings.COMPRESS_ROOT, followlinks=options['follow_links']):
|
||||
for dir_ in dirs:
|
||||
if self.is_ignored(dir_):
|
||||
dirs.remove(dir_)
|
||||
|
@@ -1,37 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import sys
|
||||
|
||||
from compressor.exceptions import FilterError
|
||||
|
||||
if sys.version_info < (2, 5):
|
||||
# Add any http://docs.python.org/library/functions.html?#any to Python < 2.5
|
||||
def any(seq):
|
||||
for item in seq:
|
||||
if item:
|
||||
return True
|
||||
return False
|
||||
|
||||
else:
|
||||
any = any
|
||||
|
||||
|
||||
if sys.version_info < (2, 6):
|
||||
def walk(root, topdown=True, onerror=None, followlinks=False):
|
||||
"""
|
||||
A version of os.walk that can follow symlinks for Python < 2.6
|
||||
"""
|
||||
for dirpath, dirnames, filenames in os.walk(root, topdown, onerror):
|
||||
yield (dirpath, dirnames, filenames)
|
||||
if followlinks:
|
||||
for d in dirnames:
|
||||
p = os.path.join(dirpath, d)
|
||||
if os.path.islink(p):
|
||||
for link_dirpath, link_dirnames, link_filenames in walk(p):
|
||||
yield (link_dirpath, link_dirnames, link_filenames)
|
||||
else:
|
||||
from os import walk
|
||||
|
||||
|
||||
def get_class(class_string, exception=FilterError):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user