summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f>2009-06-12 15:41:45 +0000
committerrfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f>2009-06-12 15:41:45 +0000
commite235edab668e368103eb495ce0dc94641b1f411f (patch)
tree95726076c06fd15cc7442fbd3465cb6ede710c1e
parent2c33fe00656c813b0986d6c0a2fbcadec38183c9 (diff)
downloadpyfilesystem-e235edab668e368103eb495ce0dc94641b1f411f.tar.gz
allow createfile/setcontents to take a file-like object as well as a string
git-svn-id: http://pyfilesystem.googlecode.com/svn/branches/rfk-ideas@167 67cdc799-7952-0410-af00-57a81ceafa0f
-rw-r--r--fs/base.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/base.py b/fs/base.py
index 4d83bef..f98a242 100644
--- a/fs/base.py
+++ b/fs/base.py
@@ -375,7 +375,13 @@ class FS(object):
f = None
try:
f = self.open(path, 'wb')
- f.write(data)
+ if hasattr(data,"read"):
+ chunk = data.read(1024*512)
+ while chunk:
+ f.write(chunk)
+ chunk = data.read(1024*512)
+ else:
+ f.write(data)
finally:
if f is not None:
f.close()