INNER CODE UNIT · Python

get_indent

Cooler2/ApusGameEngine · tools/normalize_indent.py:36

def get_indent(line):
    """Return number of leading spaces (tabs count as 1 each)."""
    return len(line) - len(line.lstrip(' '))


def detect_style(lines):
    """
    Returns:
      'one'   — 1-space per indent level (needs 2x)
      'two'   — already 2-space (skip)
      'mixed' — ambiguous (skip, report)
    """
    indents = [get_indent(l) for l in lines
               if l.strip() and not l.startswith('\t')]
    indents = [x for x in indents if x > 0]
    if not indents:
        return 'two'  # no indented lines, nothing to do

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…