summaryrefslogtreecommitdiff
path: root/coverage/misc.py
diff options
context:
space:
mode:
Diffstat (limited to 'coverage/misc.py')
-rw-r--r--coverage/misc.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/coverage/misc.py b/coverage/misc.py
index fc2a5c98..2f3bcac6 100644
--- a/coverage/misc.py
+++ b/coverage/misc.py
@@ -273,10 +273,10 @@ def substitute_variables(text, variables):
dollar_pattern = r"""(?x) # Use extended regex syntax
\$ # A dollar sign,
(?: # then
- (?P<w1>\w+) | # a plain word,
- (?P<dollar>\$) | # or a dollar sign.
- { # or a {-wrapped
- (?P<w2>\w+) # word,
+ (?P<dollar>\$) | # a dollar sign, or
+ (?P<word1>\w+) | # a plain word, or
+ { # a {-wrapped
+ (?P<word2>\w+) # word,
(?:
(?P<strict>\?) | # with a strict marker
-(?P<defval>[^}]*) # or a default value
@@ -285,19 +285,19 @@ def substitute_variables(text, variables):
)
"""
- def dollar_replace(m):
+ def dollar_replace(match):
"""Called for each $replacement."""
# Only one of the groups will have matched, just get its text.
- word = next(w for w in m.group('w1', 'w2', 'dollar') if w)
+ word = next(g for g in match.group('dollar', 'word1', 'word2') if g)
if word == "$":
return "$"
elif word in variables:
return variables[word]
- elif m.group('strict'):
+ elif match.group('strict'):
msg = "Variable {} is undefined: {!r}".format(word, text)
raise CoverageException(msg)
else:
- return m.group('defval')
+ return match.group('defval')
text = re.sub(dollar_pattern, dollar_replace, text)
return text