Returns an generator which 'walks` the input `obj` model. Each iteration yields a stix.Entity or cybox.Entity instance. This is performed depth-first.
(obj)
| 38 | |
| 39 | |
| 40 | def iterwalk(obj): |
| 41 | """Returns an generator which 'walks` the input `obj` model. Each |
| 42 | iteration yields a stix.Entity or cybox.Entity instance. |
| 43 | |
| 44 | This is performed depth-first. |
| 45 | |
| 46 | """ |
| 47 | def yield_and_walk(item): |
| 48 | if not is_entity(item): |
| 49 | return |
| 50 | |
| 51 | yield item |
| 52 | for descendant in iterwalk(item): |
| 53 | yield descendant |
| 54 | |
| 55 | for varname, varobj in _iter_vars(obj): |
| 56 | if _is_skippable(obj, varname, varobj): |
| 57 | continue |
| 58 | |
| 59 | if is_sequence(varobj) and not is_entitylist(varobj): |
| 60 | for item in varobj: |
| 61 | for descendant in yield_and_walk(item): |
| 62 | yield descendant |
| 63 | |
| 64 | continue |
| 65 | |
| 66 | for descendant in yield_and_walk(varobj): |
| 67 | yield descendant |
| 68 | |
| 69 | |
| 70 | def iterpath(obj, path=None): |
no test coverage detected