[cookbook]: https://doc.arvados.org/sdk/python/cookbook.html#working-with-collections
"""
-from __future__ import absolute_import
-from future.utils import listitems, listvalues, viewkeys
-from builtins import str
-from past.builtins import basestring
-from builtins import object
import ciso8601
import datetime
import errno
if value == self._committed:
return
if value:
- for k,v in listitems(self._items):
+ for k,v in self._items.items():
v.set_committed(True)
self._committed = True
else:
This method does not recurse. It only iterates the contents of this
collection's corresponding stream.
"""
- return iter(viewkeys(self._items))
+ return iter(self._items)
@synchronized
def __getitem__(self, k: str) -> CollectionItem:
`arvados.arvfile.ArvadosFile` for every file, directly within this
collection's stream. This method does not recurse.
"""
- return listvalues(self._items)
+ return list(self._items.values())
@synchronized
def items(self) -> List[Tuple[str, CollectionItem]]:
`arvados.arvfile.ArvadosFile` for every file, directly within this
collection's stream. This method does not recurse.
"""
- return listitems(self._items)
+ return list(self._items.items())
def exists(self, path: str) -> bool:
"""Indicate whether this collection includes an item at `path`
item.remove(pathcomponents[1], recursive=recursive)
def _clonefrom(self, source):
- for k,v in listitems(source):
+ for k,v in source.items():
self._items[k] = v.clone(self, k)
def clone(self):
source_collection = self
# Find the object
- if isinstance(source, basestring):
+ if isinstance(source, str):
source_obj = source_collection.find(source)
if source_obj is None:
raise IOError(errno.ENOENT, "File not found", source)
Arguments:
- * source: str | arvados.arvilfe.ArvadosFile |
+ * source: str | arvados.arvfile.ArvadosFile |
arvados.collection.Subcollection --- The file or subcollection to
add to this collection. If `source` is a str, the object will be
found by looking up this path from `source_collection` (see
@synchronized
def flush(self) -> None:
"""Upload any pending data to Keep"""
- for e in listvalues(self):
+ for e in self.values():
e.flush()
You may only have one file object from the Collection open at a time,
so be sure to close the object when you're done. Using the object in
- a with statement makes that easy::
+ a with statement makes that easy:
- with cwriter.open('./doc/page1.txt') as outfile:
- outfile.write(page1_data)
- with cwriter.open('./doc/page2.txt') as outfile:
- outfile.write(page2_data)
+ with cwriter.open('./doc/page1.txt') as outfile:
+ outfile.write(page1_data)
+ with cwriter.open('./doc/page2.txt') as outfile:
+ outfile.write(page2_data)
"""
if filename is None:
streampath, filename = split(streampath)
return writer
def check_dependencies(self):
- for path, orig_stat in listitems(self._dependencies):
+ for path, orig_stat in self._dependencies.items():
if not S_ISREG(orig_stat[ST_MODE]):
raise errors.StaleWriterStateError(u"{} not file".format(path))
try: