Commit ae6b3f8e by Austin Pua

Fixed Django 1.10 deprecation warnings described in #586

parent 41fced3d
...@@ -4,6 +4,7 @@ import os ...@@ -4,6 +4,7 @@ import os
from collections import OrderedDict from collections import OrderedDict
import django
from django.contrib.staticfiles import finders from django.contrib.staticfiles import finders
from django.contrib.staticfiles.storage import staticfiles_storage from django.contrib.staticfiles.storage import staticfiles_storage
from django.utils import six from django.utils import six
...@@ -19,6 +20,11 @@ class Collector(object): ...@@ -19,6 +20,11 @@ class Collector(object):
storage = staticfiles_storage storage = staticfiles_storage
self.storage = storage self.storage = storage
def _get_modified_time(self, storage, prefixed_path):
if django.VERSION[:2] >= (1, 10):
return storage.get_modified_time(prefixed_path)
return storage.modified_time(prefixed_path)
def clear(self, path=""): def clear(self, path=""):
dirs, files = self.storage.listdir(path) dirs, files = self.storage.listdir(path)
for f in files: for f in files:
...@@ -65,14 +71,14 @@ class Collector(object): ...@@ -65,14 +71,14 @@ class Collector(object):
if self.storage.exists(prefixed_path): if self.storage.exists(prefixed_path):
try: try:
# When was the target file modified last time? # When was the target file modified last time?
target_last_modified = self.storage.modified_time(prefixed_path) target_last_modified = self._get_modified_time(self.storage, prefixed_path)
except (OSError, NotImplementedError, AttributeError): except (OSError, NotImplementedError, AttributeError):
# The storage doesn't support ``modified_time`` or failed # The storage doesn't support ``modified_time`` or failed
pass pass
else: else:
try: try:
# When was the source file modified last time? # When was the source file modified last time?
source_last_modified = source_storage.modified_time(path) source_last_modified = self._get_modified_time(source_storage, prefixed_path)
except (OSError, NotImplementedError, AttributeError): except (OSError, NotImplementedError, AttributeError):
pass pass
else: else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment