The file() builtin has been removed in Python 3. Use open() instead.

This commit is contained in:
Berker Peksag
2014-06-07 13:51:42 +03:00
parent 120fa4ae95
commit d9aced73f1
8 changed files with 19 additions and 19 deletions

View File

@@ -178,7 +178,7 @@ class StorageInterface(object):
shutil.copy(self.get_local_path(filepath), dest_path)
else:
with self.get_file(filepath, 'rb') as source_file:
with file(dest_path, 'wb') as dest_file:
with open(dest_path, 'wb') as dest_file:
# Copy from remote storage in 4M chunks
shutil.copyfileobj(source_file, dest_file, length=4*1048576)
@@ -191,7 +191,7 @@ class StorageInterface(object):
your storage system.
"""
with self.get_file(filepath, 'wb') as dest_file:
with file(filename, 'rb') as source_file:
with open(filename, 'rb') as source_file:
# Copy to storage system in 4M chunks
shutil.copyfileobj(source_file, dest_file, length=4*1048576)

View File

@@ -143,7 +143,7 @@ class CloudFilesStorage(StorageInterface):
"""
# Override this method, using the "stream" iterator for efficient streaming
with self.get_file(filepath, 'rb') as source_file:
with file(dest_path, 'wb') as dest_file:
with open(dest_path, 'wb') as dest_file:
for data in source_file:
dest_file.write(data)
@@ -164,7 +164,7 @@ class CloudFilesStorage(StorageInterface):
# TODO: Fixing write() still seems worthwhile though.
_log.debug('Sending {0} to cloudfiles...'.format(filepath))
with self.get_file(filepath, 'wb') as dest_file:
with file(filename, 'rb') as source_file:
with open(filename, 'rb') as source_file:
# Copy to storage system in 4096 byte chunks
dest_file.send(source_file)