Extract the block of code at the top of the given list of lines.
(lines)
| 1218 | raise EndOfBlock |
| 1219 | |
| 1220 | def getblock(lines): |
| 1221 | """Extract the block of code at the top of the given list of lines.""" |
| 1222 | blockfinder = BlockFinder() |
| 1223 | try: |
| 1224 | tokens = tokenize.generate_tokens(iter(lines).__next__) |
| 1225 | for _token in tokens: |
| 1226 | blockfinder.tokeneater(*_token) |
| 1227 | except (EndOfBlock, IndentationError): |
| 1228 | pass |
| 1229 | return lines[:blockfinder.last] |
| 1230 | |
| 1231 | def getsourcelines(object): |
| 1232 | """Return a list of source lines and starting line number for an object. |
no test coverage detected