summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2020-03-05 09:07:10 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2020-04-27 08:32:32 +0000
commit236382d7403338ca216769de73d18ffb6f5d3fda (patch)
treecd337e6e114b74d9c2443b6c54cb551c2df03db6 /src
parentac7e20f1fb084ebe3c91cc85e0f865662115e372 (diff)
downloadbuildstream-236382d7403338ca216769de73d18ffb6f5d3fda.tar.gz
storage: Implement __iter__ in Directory classes
Diffstat (limited to 'src')
-rw-r--r--src/buildstream/storage/_casbaseddirectory.py3
-rw-r--r--src/buildstream/storage/_filebaseddirectory.py3
2 files changed, 6 insertions, 0 deletions
diff --git a/src/buildstream/storage/_casbaseddirectory.py b/src/buildstream/storage/_casbaseddirectory.py
index 6fe200de1..99cf1113f 100644
--- a/src/buildstream/storage/_casbaseddirectory.py
+++ b/src/buildstream/storage/_casbaseddirectory.py
@@ -843,6 +843,9 @@ class CasBasedDirectory(Directory):
except VirtualDirectoryError:
return False
+ def __iter__(self):
+ yield from self.index.keys()
+
def _set_subtree_read_only(self, read_only):
self.__node_properties = list(filter(lambda prop: prop.name != "SubtreeReadOnly", self.__node_properties))
node_property = remote_execution_pb2.NodeProperty()
diff --git a/src/buildstream/storage/_filebaseddirectory.py b/src/buildstream/storage/_filebaseddirectory.py
index f9a830590..1799a84b8 100644
--- a/src/buildstream/storage/_filebaseddirectory.py
+++ b/src/buildstream/storage/_filebaseddirectory.py
@@ -277,6 +277,9 @@ class FileBasedDirectory(Directory):
return utils.save_file_atomic(newpath, mode=mode, encoding=encoding)
+ def __iter__(self):
+ yield from os.listdir(self.external_directory)
+
def __str__(self):
# This returns the whole path (since we don't know where the directory started)
# which exposes the sandbox directory; we will have to assume for the time being