(node, path)
| 162 | seen.update(id(token) for token in root_comment[1]) |
| 163 | |
| 164 | def walk(node, path): |
| 165 | if isinstance(node, CommentedMap): |
| 166 | items = node.items() |
| 167 | is_map = True |
| 168 | elif isinstance(node, CommentedSeq): |
| 169 | items = enumerate(node) |
| 170 | is_map = False |
| 171 | else: |
| 172 | return |
| 173 | node_comment = getattr(node.ca, "comment", None) |
| 174 | if path and node_comment and len(node_comment) > 1: |
| 175 | take_lines(node_comment[1]) |
| 176 | for key, value in items: |
| 177 | item_path = path + (_ruamel_to_builtin(key),) |
| 178 | if pending: |
| 179 | entry(item_path)["before"].extend(pending) |
| 180 | pending.clear() |
| 181 | tokens = node.ca.items.get(key) |
| 182 | if tokens: |
| 183 | if is_map: |
| 184 | handle(tokens[2], item_path) |
| 185 | take_lines(tokens[3]) # comment lines between "key:" and its nested value |
| 186 | else: |
| 187 | handle(tokens[0], item_path) |
| 188 | walk(value, item_path) |
| 189 | |
| 190 | walk(root, ()) |
| 191 | if pending: |
no test coverage detected