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