class project_root_directories_iterator¶
Iterator over the set of root directories( directory ) in a project (deduced by inspecting all source file paths in the project).
Initialize with project.root_directories().
Use as you would any other Python iterator. For example:
# set up project proj, then...
for e in proj.root_directories():
print('directory: ', e)
project_root_directories_iterator Members¶
| Constructors | none |
| Methods | __eq__(), __iter__(), __ne__(), __next__(), __repr__(), __str__(), at_end() |
project_root_directories_iterator Details¶
-
class
cs.project_root_directories_iterator¶ Iterator over the set of root directories(
directory) in a project (deduced by inspecting all source file paths in the project).-
__eq__(other)¶ Iterator equality.
Parameters: other ( project_root_directories_iterator) –Return type: bool Returns: Trueif and only ifselfandotherare at the same position. Behavior is undefined ifselfandotherare not iterating over the same collection.>>> rd_iterA = project.current().root_directories() >>> rd_iterB = project.current().root_directories() >>> rd_iterA == rd_iterB True >>> for rd in rd_iterA: ... if len(list(rd.children()))>1: ... break ... >>> rd_iterA == rd_iterB False
-
__iter__()¶ Get the iterator object.
Return type: project_root_directories_iteratorReturns: self.>>> for rd in project.current().root_directories(): # iteration managed by project_root_directories_iterator.__iter__() ... # and project_root_directories_iterator.__next__() ... print(rd) ... C:\cygwin\home\alex\ C:
-
__ne__(other)¶ Iterator inequality.
Parameters: other ( project_root_directories_iterator) – The iterator to compare against.Return type: bool Returns: Falseif and only ifselfandotherare at the same position. Behavior is undefined ifselfandotherare not iterating over the same collection.>>> rd_iterA = project.current().root_directories() >>> rd_iterB = project.current().root_directories() >>> rd_iterA != rd_iterB False >>> for rd in rd_iterA: ... if len(list(rd.children()))>1: ... break ... >>> rd_iterA != rd_iterB True
-
__next__()¶ Iterator dereference operator.
Return type: directoryReturns: 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)
>>> for rd in project.current().root_directories(): # iteration managed by project_root_directories_iterator.__iter__() ... # and project_root_directories_iterator.__next__() ... print(rd) ... C:\cygwin\home\alex\ C:
- Side effects: Modifies
-
__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() >>> repr(v1) '<cs.project_root_directories_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() >>> str(v1) '<cs.project_root_directories_iterator begin>'
-
at_end()¶ Check: is the iterator at the end of the structure?
Return type: bool Returns: Trueif the iterator is at the end of the structure (there are no more elements to iterate over),Falseotherwise.>>> v0 = project.current() >>> v1 = v0.root_directories() >>> v1.at_end() False
-