raise IOError((errno.ENOENT, "File not found"))
def _cloneinto(self, target):
- for k,v in self._items:
- target._items[k] = v.clone(new_parent=target)
+ for k,v in self._items.items():
+ target._items[k] = v.clone(target)
def clone(self):
raise NotImplementedError()
@_must_be_writable
@_synchronized
def copy(self, source_path, target_path, source_collection=None, overwrite=False):
- """
- copyto('/foo', '/bar') will overwrite 'foo' if it exists.
- copyto('/foo/', '/bar') will place 'bar' in subcollection 'foo'
+ """Copy a file or subcollection to a new path in this collection.
+
+ :source_path:
+ Source file or subcollection
+
+ :target_path:
+ Destination file or path. If the target path already exists and is a
+ subcollection, the item will be placed inside the subcollection. If
+ the target path already exists and is a file, this will raise an error
+ unless you specify `overwrite=True`.
+
+ :source_collection:
+ Collection to copy `source_path` from (default `self`)
+
+ :overwrite:
+ Whether to overwrite target file if it already exists.
"""
if source_collection is None:
source_collection = self
self[k].merge(other[k])
else:
if self[k] != other[k]:
- name = "%s~conflict-%s~" % (k, time.strftime("%Y-%m-%d_%H:%M%:%S",
+ name = "%s~conflict-%s~" % (k, time.strftime("%Y-%m-%d_%H:%M:%S",
time.gmtime()))
- self[name] = other[k].clone(self)
+ self._items[name] = other[k].clone(self)
self.notify(self, name, ADD, self[name])
else:
- self[k] = other[k].clone(self)
+ self._items[k] = other[k].clone(self)
self.notify(self, k, ADD, self[k])
def portable_data_hash(self):
@_synchronized
def clone(self, new_parent=None, new_sync=SYNC_READONLY, new_config=None):
if new_config is None:
- new_config = self.config
+ new_config = self._config
c = Collection(parent=new_parent, config=new_config, sync=new_sync)
if new_sync == SYNC_READONLY:
c.lock = NoopLock()