Move the copyfile function to the common app
This commit is contained in:
@@ -4,29 +4,6 @@ from django.core.exceptions import ImproperlyConfigured
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
|
||||
#http://stackoverflow.com/questions/123198/how-do-i-copy-a-file-in-python
|
||||
def copyfile(source, dest, buffer_size=1024 * 1024):
|
||||
"""
|
||||
Copy a file from source to dest. source and dest
|
||||
can either be strings or any object with a read or
|
||||
write method, like StringIO for example.
|
||||
"""
|
||||
if not hasattr(source, 'read'):
|
||||
source = open(source, 'rb')
|
||||
if not hasattr(dest, 'write'):
|
||||
dest = open(dest, 'wb')
|
||||
|
||||
while 1:
|
||||
copy_buffer = source.read(buffer_size)
|
||||
if copy_buffer:
|
||||
dest.write(copy_buffer)
|
||||
else:
|
||||
break
|
||||
|
||||
source.close()
|
||||
dest.close()
|
||||
|
||||
|
||||
def _lazy_load(fn):
|
||||
_cached = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user