class directory_children_iterator

Iterator over the immediate subdirectories ( directory ) of a directory ( directory ).

Initialize with directory.children().

Use as you would any other Python iterator. For example:

# set up directory dir, then...
for e in dir.children():
    print('directory: ', e)

directory_children_iterator Details

class cs.directory_children_iterator

Iterator over the immediate subdirectories ( directory ) of a directory ( directory ).

__eq__(other)

Iterator equality.

Parameters:other (directory_children_iterator) –
Return type:bool
Returns:True if and only if self and other are at the same position. Behavior is undefined if self and other are not iterating over the same collection.
>>> rdir = list(project.current().root_directories())[0]
>>> dirch_iterA = rdir.children()
>>> dirch_iterB = rdir.children()
>>> dirch_iterA == dirch_iterB
True
>>> for d in dirch_iterA:
...    print(d)              # paths will depend on your local system
...
C:\cygwin\home\alex\codesonar
C:\cygwin\home\alex\csurf
>>> dirch_iterA == dirch_iterB
False
__iter__()

Get the iterator object.

Return type:directory_children_iterator
Returns:self.
>>> v0 = project.current()
>>> v1 = v0.root_directories()
>>> v2 = next(v1)
>>> v3 = v2.children()
>>> iter(v3)
<cs.directory_children_iterator begin>
__ne__(other)

Iterator inequality.

Parameters:other (directory_children_iterator) – The iterator to compare against.
Return type:bool
Returns:False if and only if self and other are at the same position. Behavior is undefined if self and other are not iterating over the same collection.
>>> rdir = list(project.current().root_directories())[0]
>>> dirch_iterA = rdir.children()
>>> dirch_iterB = rdir.children()
>>> dirch_iterA != dirch_iterB
False
>>> for d in dirch_iterA:
...    print(d)              # paths will depend on your local system
...
C:\cygwin\home\alex\codesonar
C:\cygwin\home\alex\csurf
>>> dirch_iterA != dirch_iterB
True
__next__()

Iterator dereference operator.

Return type:directory
Returns:The element at the current iterator position.
Raises:StopIteration
  • Side effects: Modifies self.

The typical use is implicit:

>>> for item in myiter:
...   (do something to item)
>>> v0 = project.current()
>>> v1 = v0.root_directories()
>>> v2 = next(v1)
>>> v3 = v2.children()
>>> next(v3)
<cs.directory /mys0/alex/trunk/cso-tests>
__repr__()

Get a representation of the iterator that includes information useful for debugging.

Return type:str
Returns:The string representation.
>>> v0 = project.current()
>>> v1 = v0.root_directories()
>>> v2 = next(v1)
>>> v3 = v2.children()
>>> repr(v3)
'<cs.directory_children_iterator begin>'
__str__()

Get a simple string representation of the iterator.

Return type:str
Returns:The string representation.
>>> v0 = project.current()
>>> v1 = v0.root_directories()
>>> v2 = next(v1)
>>> v3 = v2.children()
>>> str(v3)
'<cs.directory_children_iterator begin>'
at_end()

Check: is the iterator at the end of the structure?

Return type:bool
Returns:True if the iterator is at the end of the structure (there are no more elements to iterate over), False otherwise.
>>> v0 = project.current()
>>> v1 = v0.root_directories()
>>> v2 = next(v1)
>>> v3 = v2.children()
>>> v3.at_end()
False