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

Function get_line_indent

Lib/idlelib/format.py:202–209  ·  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

200_line_indent_re = re.compile(r'[ \t]*')
201
202def get_line_indent(line, tabwidth):
203 """Return a line's indentation as (# chars, effective # of spaces).
204
205 The effective # of spaces is the length after properly "expanding"
206 the tabs into spaces, as done by str.expandtabs(tabwidth).
207 """
208 m = _line_indent_re.match(line)
209 return m.end(), len(m.group().expandtabs(tabwidth))
210
211
212class FormatRegion:

Callers 3

indent_region_eventMethod · 0.70
dedent_region_eventMethod · 0.70
tabify_region_eventMethod · 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…