diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2015-06-04 20:48:10 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2015-06-04 20:48:49 +0200 |
| commit | 4ece4de43b29da747e18447d0de0480ff36545bf (patch) | |
| tree | 218296fb2baaa492bf9ed057a9ad778595771e5e /kconfiglib.py | |
| parent | 52dbfb144f5c91d2f30ac2b83937958b211875ee (diff) | |
Refactor and optimize _strip_quotes().
Use the fact that startswith() can check multiple prefixes.
Diffstat (limited to 'kconfiglib.py')
| -rw-r--r-- | kconfiglib.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index abc42ca..c9613de 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -3668,12 +3668,10 @@ def tri_greater_eq(v1, v2): # def _strip_quotes(s, line, filename, linenr): - """Removes any quotes surrounding 's' if it has them; otherwise returns 's' - unmodified.""" + """Strips leading and trailing whitespace from 's' and then strips any + surrounding quotes.""" s = s.strip() - if not s: - return "" - if s[0] == '"' or s[0] == "'": + if s.startswith(('"', "'")): if len(s) < 2 or s[-1] != s[0]: _parse_error(line, "malformed string literal", |
