Skip to content

Commit e91a4c7

Browse files
committed
use **kwargs in copy() signature
1 parent c8d2708 commit e91a4c7

File tree

14 files changed

+39
-35
lines changed

14 files changed

+39
-35
lines changed

fs/base.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ def _setcontents(self,
803803
chunk_size=1024 * 64,
804804
progress_callback=None,
805805
finished_callback=None,
806-
bypass_lock=False):
806+
**kwargs):
807807
"""Does the work of setcontents. Factored out, so that `setcontents_async` can use it"""
808808
if progress_callback is None:
809809
progress_callback = lambda bytes_written: None
@@ -824,9 +824,9 @@ def _setcontents(self,
824824
chunk = read(chunk_size)
825825
if isinstance(chunk, six.text_type):
826826
f = self.open(path, 'wt', encoding=encoding, errors=errors,
827-
bypass_lock=bypass_lock)
827+
**kwargs)
828828
else:
829-
f = self.open(path, 'wb', bypass_lock=bypass_lock)
829+
f = self.open(path, 'wb', **kwargs)
830830
write = f.write
831831
try:
832832
while chunk:
@@ -851,7 +851,7 @@ def _setcontents(self,
851851
return bytes_written
852852

853853
def setcontents(self, path, data=b'', encoding=None, errors=None,
854-
chunk_size=1024 * 64, bypass_lock=False):
854+
chunk_size=1024 * 64, **kwargs):
855855
"""A convenience method to create a new file from a string or file-like object
856856
857857
:param path: a path of the file to create
@@ -861,7 +861,7 @@ def setcontents(self, path, data=b'', encoding=None, errors=None,
861861
:param chunk_size: Number of bytes to read in a chunk, if the implementation has to resort to a read / copy loop
862862
863863
"""
864-
return self._setcontents(path, data, encoding=encoding, errors=errors, chunk_size=1024 * 64, bypass_lock=bypass_lock)
864+
return self._setcontents(path, data, encoding=encoding, errors=errors, chunk_size=1024 * 64, **kwargs)
865865

866866
def setcontents_async(self,
867867
path,
@@ -1113,7 +1113,7 @@ def getsize(self, path):
11131113
raise OperationFailedError("get size of resource", path)
11141114
return size
11151115

1116-
def copy(self, src, dst, overwrite=False, chunk_size=1024 * 64):
1116+
def copy(self, src, dst, overwrite=False, chunk_size=1024 * 64, **kwargs):
11171117
"""Copies a file from src to dst.
11181118
11191119
:param src: the source path

fs/contrib/davfs/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def new_close():
346346
raise RemoteConnectionError("",msg=msg,details=e)
347347

348348
def setcontents(self,path, data=b'', encoding=None, errors=None,
349-
chunk_size=1024 * 64, bypass_lock=False):
349+
chunk_size=1024 * 64, **kwargs):
350350
if isinstance(data, six.text_type):
351351
data = data.encode(encoding=encoding, errors=errors)
352352
resp = self._request(path, "PUT", data)
@@ -679,7 +679,7 @@ def _info_from_propfind(self,res):
679679
return info
680680

681681

682-
def copy(self,src,dst,overwrite=False,chunk_size=None):
682+
def copy(self, src, dst, overwrite=False, chunk_size=None, **kwargs):
683683
if self.isdir(src):
684684
msg = "Source is not a file: %(path)s"
685685
raise ResourceInvalidError(src, msg=msg)

fs/contrib/tahoelafs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def getrange(self, path, offset, length=None):
361361
offset=offset, length=length)
362362

363363
@_fix_path
364-
def setcontents(self, path, file, chunk_size=64*1024, bypass_lock=False):
364+
def setcontents(self, path, file, chunk_size=64*1024, **kwargs):
365365
self._log(INFO, 'Uploading file %s' % path)
366366
size=None
367367

fs/expose/xmlrpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def listxattrs(self, path):
155155
path = self.decode_path(path)
156156
return [self.encode_path(a) for a in self.fs.listxattrs(path)]
157157

158-
def copy(self, src, dst, overwrite=False, chunk_size=16384):
158+
def copy(self, src, dst, overwrite=False, chunk_size=16384, **kwargs):
159159
src = self.decode_path(src)
160160
dst = self.decode_path(dst)
161161
return self.fs.copy(src, dst, overwrite, chunk_size)

fs/ftpfs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ def open(self, path, mode, buffering=-1, encoding=None, errors=None, newline=Non
11731173

11741174
@ftperrors
11751175
def setcontents(self, path, data=b'', encoding=None, errors=None,
1176-
chunk_size=1024*64, bypass_lock=False):
1176+
chunk_size=1024*64, **kwargs):
11771177
path = normpath(path)
11781178
data = iotools.make_bytes_io(data, encoding=encoding, errors=errors)
11791179
self.refresh_dircache(dirname(path))
@@ -1403,7 +1403,7 @@ def move(self, src, dst, overwrite=False, chunk_size=16384):
14031403
self.refresh_dircache(src, dirname(src), dst, dirname(dst))
14041404

14051405
@ftperrors
1406-
def copy(self, src, dst, overwrite=False, chunk_size=1024*64):
1406+
def copy(self, src, dst, overwrite=False, chunk_size=1024*64, **kwargs):
14071407
if not self.isfile(src):
14081408
if self.isdir(src):
14091409
raise ResourceInvalidError(src, msg="Source is not a file: %(path)s")

fs/memoryfs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,12 +608,12 @@ def movedir(self, src, dst, overwrite=False, ignore_errors=False, chunk_size=102
608608
dst_dir_entry.xattrs.update(src_xattrs)
609609

610610
@synchronize
611-
def copy(self, src, dst, overwrite=False, chunk_size=1024*64):
611+
def copy(self, src, dst, overwrite=False, chunk_size=1024*64, **kwargs):
612612
src_dir_entry = self._get_dir_entry(src)
613613
if src_dir_entry is None:
614614
raise ResourceNotFoundError(src)
615615
src_xattrs = src_dir_entry.xattrs.copy()
616-
super(MemoryFS, self).copy(src, dst, overwrite, chunk_size)
616+
super(MemoryFS, self).copy(src, dst, overwrite, chunk_size, **kwargs)
617617
dst_dir_entry = self._get_dir_entry(dst)
618618
if dst_dir_entry is not None:
619619
dst_dir_entry.xattrs.update(src_xattrs)
@@ -643,7 +643,7 @@ def getcontents(self, path, mode="rb", encoding=None, errors=None, newline=None)
643643

644644
@synchronize
645645
def setcontents(self, path, data=b'', encoding=None, errors=None,
646-
chunk_size=1024*64, bypass_lock=False):
646+
chunk_size=1024*64, **kwargs):
647647
if isinstance(data, six.binary_type):
648648
if not self.exists(path):
649649
self.open(path, 'wb').close()
@@ -657,7 +657,7 @@ def setcontents(self, path, data=b'', encoding=None, errors=None,
657657

658658
return super(MemoryFS, self).setcontents(
659659
path, data=data, encoding=encoding, errors=errors,
660-
chunk_size=chunk_size, bypass_lock=bypass_lock)
660+
chunk_size=chunk_size, **kwargs)
661661

662662
# if isinstance(data, six.text_type):
663663
# return super(MemoryFS, self).setcontents(path, data, encoding=encoding, errors=errors, chunk_size=chunk_size)

fs/mountfs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,19 +313,19 @@ def open(self, path, mode='r', buffering=-1, encoding=None, errors=None, newline
313313

314314
@synchronize
315315
def setcontents(self, path, data=b'', encoding=None, errors=None,
316-
chunk_size=64*1024, bypass_lock=False):
316+
chunk_size=64*1024, **kwargs):
317317
obj = self.mount_tree.get(path, None)
318318
if type(obj) is MountFS.FileMount:
319319
return super(MountFS, self).setcontents(path,
320320
data,
321321
encoding=encoding,
322322
errors=errors,
323323
chunk_size=chunk_size,
324-
bypass_lock=bypass_lock)
324+
**kwargs)
325325
fs, _mount_path, delegate_path = self._delegate(path)
326326
if fs is self or fs is None:
327327
raise ParentDirectoryMissingError(path)
328-
return fs.setcontents(delegate_path, data, encoding=encoding, errors=errors, chunk_size=chunk_size, bypass_lock=False)
328+
return fs.setcontents(delegate_path, data, encoding=encoding, errors=errors, chunk_size=chunk_size)
329329

330330
@synchronize
331331
def createfile(self, path, wipe=False):

fs/osfs/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,10 @@ def open(self, path, mode='r', buffering=-1, encoding=None, errors=None, newline
239239

240240
@convert_os_errors
241241
def setcontents(self, path, data=b'', encoding=None, errors=None,
242-
chunk_size=64 * 1024, bypass_lock=False):
242+
chunk_size=64 * 1024, **kwargs):
243243
return super(OSFS, self).setcontents(
244244
path, data, encoding=encoding, errors=errors,
245-
chunk_size=chunk_size, bypass_lock=bypass_lock)
245+
chunk_size=chunk_size, **kwargs)
246246

247247
@convert_os_errors
248248
def exists(self, path):

fs/remote.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,9 @@ def __init__(self,wrapped_fs,poll_interval=None,connected=True):
318318
self.connected = connected
319319

320320
def setcontents(self, path, data=b'', encoding=None, errors=None,
321-
chunk_size=64*1024, bypass_lock=False):
321+
chunk_size=64*1024, **kwargs):
322322
return self.wrapped_fs.setcontents(path, data, encoding=encoding,
323-
errors=errors, chunk_size=chunk_size, bypass_lock=bypass_lock)
323+
errors=errors, chunk_size=chunk_size)
324324

325325
def __getstate__(self):
326326
state = super(ConnectionManagerFS,self).__getstate__()
@@ -675,10 +675,10 @@ def getsize(self,path):
675675
return self.getinfo(path)["size"]
676676

677677
def setcontents(self, path, data=b'', encoding=None, errors=None,
678-
chunk_size=64*1024, bypass_lock=False):
678+
chunk_size=64*1024, **kwargs):
679679
supsc = super(CacheFSMixin, self).setcontents
680680
res = supsc(path, data, encoding=None, errors=None,
681-
chunk_size=chunk_size, bypass_lock=bypass_lock)
681+
chunk_size=chunk_size, **kwargs)
682682
with self.__cache_lock:
683683
self.__cache.clear(path)
684684
self.__cache[path] = CachedInfo.new_file_stub()

fs/s3fs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def getpathurl(self, path, allow_none=False, expires=3600):
273273
return url
274274

275275
def setcontents(self, path, data=b'', encoding=None, errors=None,
276-
chunk_size=64*1024, bypass_lock=False):
276+
chunk_size=64*1024, **kwargs):
277277
s3path = self._s3path(path)
278278
if isinstance(data, six.text_type):
279279
data = data.encode(encoding=encoding, errors=errors)
@@ -595,7 +595,7 @@ def _get_key_info(self,key,name=None):
595595
def desc(self,path):
596596
return "No description available"
597597

598-
def copy(self,src,dst,overwrite=False,chunk_size=16384):
598+
def copy(self,src,dst,overwrite=False,chunk_size=16384, **kwargs):
599599
"""Copy a file from 'src' to 'dst'.
600600
601601
src -- The source path

0 commit comments

Comments
 (0)