MCPcopy Create free account
hub / github.com/ActiveState/code / next

Method next

recipes/Python/184602_Directory_Iterator/recipe-184602.py:10–22  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

8 def __iter__(self):
9 return self
10 def next(self):
11 if self._files:
12 join = os.path.join
13 d = self._files.pop()
14 r = join(self._root, d)
15 if self.deep and os.path.isdir(r):
16 self._files += [join(d,n) for n in os.listdir(r)]
17 elif self._files is None:
18 self._files = os.listdir(self._root)
19 if self._files:
20 return self._files[-1]
21 else:
22 raise StopIteration
23
24
25# sample:

Callers 1

recipe-189060.pyFile · 0.45

Calls 4

isdirMethod · 0.80
joinFunction · 0.50
popMethod · 0.45
listdirMethod · 0.45

Tested by

no test coverage detected