class project_sfiles_iterator¶
Iterator over all the source files ( sfile ) in a project .
Initialize with project.sfiles().
Use as you would any other Python iterator. For example:
# set up project proj, then...
for e in proj.sfiles():
print('sfile: ', e)
project_sfiles_iterator Members¶
| Constructors | none |
| Methods | __eq__(), __iter__(), __ne__(), __next__(), __repr__(), __str__(), at_end() |
project_sfiles_iterator Details¶
-
class
cs.project_sfiles_iterator¶ Iterator over all the source files (
sfile) in aproject.-
__eq__(other)¶ Iterator equality.
Parameters: other ( project_sfiles_iterator) –Return type: bool Returns: Trueif and only ifselfandotherare at the same position. Behavior is undefined ifselfandotherare not iterating over the same collection.>>> sf_iterA = project.current().sfiles() >>> sf_iterB = project.current().sfiles() >>> sf_iterA == sf_iterB True >>> for sf in sf_iterA: ... if sf.name().endswith('apitest.cpp'): ... break ... >>> sf_iterA == sf_iterB False
-
__iter__()¶ Get the iterator object.
Return type: project_sfiles_iteratorReturns: self.>>> for sf in project.current().sfiles(): # iteration managed by project_sfiles_iterator.__iter__() ... # and project_sfiles_iterator.__next__() ... if 'apitest' in sf.name(): ... print(sf) ... C:\cygwin\home\alex\testmicros\API\apitest.cpp C:\cygwin\home\alex\testmicros\API\apitest.h
-
__ne__(other)¶ Iterator inequality.
Parameters: other ( project_sfiles_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.>>> sf_iterA = project.current().sfiles() >>> sf_iterB = project.current().sfiles() >>> sf_iterA != sf_iterB False >>> for sf in sf_iterA: ... if sf.name().endswith('apitest.cpp'): ... break ... >>> sf_iterA != sf_iterB True
-
__next__()¶ Iterator dereference operator.
Return type: sfileReturns: 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 sf in project.current().sfiles(): # iteration managed by project_sfiles_iterator.__iter__() ... # and project_sfiles_iterator.__next__() ... if 'apitest' in sf.name(): ... print(sf) ... C:\cygwin\home\alex\testmicros\API\apitest.cpp C:\cygwin\home\alex\testmicros\API\apitest.h
- 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.sfiles() >>> repr(v1) '<cs.project_sfiles_iterator begin>'
-
__str__()¶ Get a simple string representation of the iterator.
Return type: str Returns: The string representation. >>> v0 = project.current() >>> v1 = v0.sfiles() >>> str(v1) '<cs.project_sfiles_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.sfiles() >>> v1.at_end() False
-