MCPcopy Index your code
hub / github.com/python/cpython / get_line_indent

Function get_line_indent

Lib/idlelib/editor.py:1565–1572  ·  view source on GitHub ↗

Return a line's indentation as (# chars, effective # of spaces). The effective # of spaces is the length after properly "expanding" the tabs into spaces, as done by str.expandtabs(tabwidth).

(line, tabwidth)

Source from the content-addressed store, hash-verified

1563
1564_line_indent_re = re.compile(r'[ \t]*')
1565def get_line_indent(line, tabwidth):
1566 """Return a line's indentation as (# chars, effective # of spaces).
1567
1568 The effective # of spaces is the length after properly "expanding"
1569 the tabs into spaces, as done by str.expandtabs(tabwidth).
1570 """
1571 m = _line_indent_re.match(line)
1572 return m.end(), len(m.group().expandtabs(tabwidth))
1573
1574
1575class IndentSearcher:

Callers 2

smart_indent_eventMethod · 0.70
guess_indentMethod · 0.70

Calls 4

matchMethod · 0.45
endMethod · 0.45
expandtabsMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…