Skip to content

Commit

Permalink
changed setbin to setbinfile
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Dec 4, 2016
1 parent e80bd65 commit 1fc0f9d
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions fs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def copy(self, src_path, dst_path, overwrite=False):
if not overwrite and self.exists(dst_path):
raise errors.DestinationExists(dst_path)
with closing(self.open(src_path, 'rb')) as read_file:
self.setbin(dst_path, read_file)
self.setbinfile(dst_path, read_file)

def copydir(self, src_path, dst_path, create=False):
"""
Expand Down Expand Up @@ -818,7 +818,7 @@ def move(self,
return
with self._lock:
with self.open(src_path, 'rb') as read_file:
self.setbin(dst_path, read_file)
self.setbinfile(dst_path, read_file)
self.remove(src_path)

def open(self,
Expand Down Expand Up @@ -945,7 +945,7 @@ def setbytes(self, path, contents):
with closing(self.open(path, mode='wb')) as write_file:
write_file.write(contents)

def setbin(self, path, file):
def setbinfile(self, path, file):
"""
Set a file to the contents of a binary file object.
Expand All @@ -962,7 +962,7 @@ def setbin(self, path, file):
(ideally with a context manager). For example::
with open('myfile.bin') as read_file:
my_fs.setbin('myfile.bin', read_file)
my_fs.setbinfile('myfile.bin', read_file)
"""

Expand Down
2 changes: 1 addition & 1 deletion fs/copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def copy_file(src_fs, src_path, dst_fs, dst_path):
with src_fs.lock(), dst_fs.lock():
with src_fs.open(src_path, 'rb') as read_file:
# There may be an optimized copy available on dst_fs
dst_fs.setbin(dst_path, read_file)
dst_fs.setbinfile(dst_path, read_file)


def copy_structure(src_fs, dst_fs, walker=None):
Expand Down
2 changes: 1 addition & 1 deletion fs/ftpfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ def scandir(self, path, namespaces=None, page=None):
iter_info = itertools.islice(iter_info, start, end)
return iter_info

def setbin(self, path, file):
def setbinfile(self, path, file):
_path = abspath(normpath(path))
self.validatepath(path)
with self._lock:
Expand Down
4 changes: 2 additions & 2 deletions fs/mountfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ def open(self,
**options
)

def setbin(self, path, file):
def setbinfile(self, path, file):
self.check()
fs, _path = self._delegate(path)
return fs.setbin(path, file)
return fs.setbinfile(path, file)

def setbytes(self, path, contents):
self.check()
Expand Down
4 changes: 2 additions & 2 deletions fs/multifs.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,9 @@ def open(self,
**kwargs
)

def setbin(self, path, file):
def setbinfile(self, path, file):
self._require_writable(path)
self.write_fs.setbin(path, file)
self.write_fs.setbinfile(path, file)

def setbytes(self, path, contents):
self._require_writable(path)
Expand Down
4 changes: 2 additions & 2 deletions fs/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,9 +1204,9 @@ def test_setfile(self):
data = f.read()
self.assertEqual(data, b'bar')

def test_setbin(self):
def test_setbinfile(self):
bytes_file = io.BytesIO(b'bar')
self.fs.setbin('foo', bytes_file)
self.fs.setbinfile('foo', bytes_file)
with self.fs.open('foo', 'rb') as f:
data = f.read()
self.assertEqual(data, b'bar')
Expand Down
2 changes: 1 addition & 1 deletion fs/wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def setbytes(self, path, contents):
self.check()
raise ResourceReadOnly(path)

def setbin(self, path, file):
def setbinfile(self, path, file):
self.check()
raise ResourceReadOnly(path)

Expand Down
4 changes: 2 additions & 2 deletions fs/wrapfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,11 @@ def setbytes(self, path, contents):
with unwrap_errors(path):
_fs.setbytes(_path, contents)

def setbin(self, path, file):
def setbinfile(self, path, file):
self.check()
_fs, _path = self.delegate_path(path)
with unwrap_errors(path):
_fs.setbin(_path, file)
_fs.setbinfile(_path, file)

def setfile(self,
path,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_readonly(self):
fs.touch('foo')

with self.assertRaises(errors.ResourceReadOnly):
fs.setbin('foo', None)
fs.setbinfile('foo', None)

with self.assertRaises(errors.ResourceReadOnly):
fs.setfile('foo', None)
Expand Down

0 comments on commit 1fc0f9d

Please sign in to comment.