MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / getblock

Function getblock

tools/python-3.11.9-amd64/Lib/inspect.py:1220–1229  ·  view source on GitHub ↗

Extract the block of code at the top of the given list of lines.

(lines)

Source from the content-addressed store, hash-verified

1218 raise EndOfBlock
1219
1220def 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
1231def getsourcelines(object):
1232 """Return a list of source lines and starting line number for an object.

Callers 1

getsourcelinesFunction · 0.85

Calls 2

tokeneaterMethod · 0.95
BlockFinderClass · 0.85

Tested by

no test coverage detected