INNER CODE UNIT · Python

detect_style

Cooler2/ApusGameEngine · tools/normalize_indent.py:41

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

    total = len(indents)
    odd = sum(1 for x in indents if x % 2 != 0)
    pct = 100 * odd // total

    if pct > 20:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…