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

Function _find_strings

tools/python-3.11.9-amd64/Lib/trace.py:350–371  ·  view source on GitHub ↗

Return a dict of possible docstring positions. The dict maps line numbers to strings. There is an entry for line that contains only a string or a part of a triple-quoted string.

(filename, encoding=None)

Source from the content-addressed store, hash-verified

348 return linenos
349
350def _find_strings(filename, encoding=None):
351 """Return a dict of possible docstring positions.
352
353 The dict maps line numbers to strings. There is an entry for
354 line that contains only a string or a part of a triple-quoted
355 string.
356 """
357 d = {}
358 # If the first token is a string, then it's the module docstring.
359 # Add this special case so that the test in the loop passes.
360 prev_ttype = token.INDENT
361 with open(filename, encoding=encoding) as f:
362 tok = tokenize.generate_tokens(f.readline)
363 for ttype, tstr, start, end, line in tok:
364 if ttype == token.STRING:
365 if prev_ttype == token.INDENT:
366 sline, scol = start
367 eline, ecol = end
368 for i in range(sline, eline + 1):
369 d[i] = 1
370 prev_ttype = ttype
371 return d
372
373def _find_executable_linenos(filename):
374 """Return dict where keys are line numbers in the line number table."""

Callers 1

_find_executable_linenosFunction · 0.85

Calls 1

openFunction · 0.70

Tested by

no test coverage detected