diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2015-06-04 20:49:52 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2015-06-04 20:51:09 +0200 |
| commit | 890c39aca8ac2f3932d61c59a2a186dbe12a0c44 (patch) | |
| tree | ee31d75022320e8167a5375f5aa74d37951dea6e /kconfiglib.py | |
| parent | 4ece4de43b29da747e18447d0de0480ff36545bf (diff) | |
Refactor and optimize _indentation().
I must have missed that expandtabs() already takes the context of tabs
into account the first time around.
Also remove error check that probably won't be useful.
Diffstat (limited to 'kconfiglib.py')
| -rw-r--r-- | kconfiglib.py | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index c9613de..367de07 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -3681,19 +3681,10 @@ def _strip_quotes(s, line, filename, linenr): return s def _indentation(line): - """Returns the indentation of the line, treating tab stops as being spaced - 8 characters apart.""" - if line.isspace(): - _internal_error("Attempt to take indentation of blank line.") - indent = 0 - for c in line: - if c == " ": - indent += 1 - elif c == "\t": - # Go to the next tab stop - indent = (indent + 8) & ~7 - else: - return indent + """Returns the length of the line's leading whitespace, treating tab stops + as being spaced 8 characters apart.""" + line = line.expandtabs() + return len(line) - len(line.lstrip()) def _deindent(line, indent): """Deindent 'line' by 'indent' spaces.""" |
