diff options
| author | Erik Rose <ErikRose@psu.edu> | 2010-02-24 23:54:59 -0500 |
|---|---|---|
| committer | Erik Rose <ErikRose@psu.edu> | 2010-02-24 23:54:59 -0500 |
| commit | 9a3fbf1065c9fca4d9e7622612a616f0e5957bb6 (patch) | |
| tree | da1b02e224749c0bbf8d8530bb12a36eca05062c /src/distutils2 | |
| parent | 5cdeab0e586216e0b14ba237bf8f0cb2baa6aeb8 (diff) | |
| download | disutils2-9a3fbf1065c9fca4d9e7622612a616f0e5957bb6.tar.gz | |
Nudged curly-brace variable substitution grammar to allow the future option of nested substitutions. Whee!
Diffstat (limited to 'src/distutils2')
| -rw-r--r-- | src/distutils2/_backport/sysconfig.py | 2 | ||||
| -rw-r--r-- | src/distutils2/_backport/tests/test_sysconfig.py | 14 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/distutils2/_backport/sysconfig.py b/src/distutils2/_backport/sysconfig.py index 62ff8ca..16a0fac 100644 --- a/src/distutils2/_backport/sysconfig.py +++ b/src/distutils2/_backport/sysconfig.py @@ -16,7 +16,7 @@ _CONFIG_DIR = os.path.normpath(os.path.dirname(__file__)) _CONFIG_FILE = os.path.join(_CONFIG_DIR, 'sysconfig.cfg') _SCHEMES = ConfigParser() _SCHEMES.read(_CONFIG_FILE) -_VAR_REPL = re.compile(r'\{(.*?)\}') +_VAR_REPL = re.compile(r'\{([^{]*?)\}') def _expand_globals(config): globals = config.items('globals') diff --git a/src/distutils2/_backport/tests/test_sysconfig.py b/src/distutils2/_backport/tests/test_sysconfig.py index 294ed5c..b51bb10 100644 --- a/src/distutils2/_backport/tests/test_sysconfig.py +++ b/src/distutils2/_backport/tests/test_sysconfig.py @@ -87,9 +87,17 @@ class TestSysConfig(unittest2.TestCase): elif os.path.isdir(path): shutil.rmtree(path) - def test_var_expansion_pattern(self): - """Assert that the {curly brace token} expansion pattern counts the second { as part of the substitution key in expressions like {{something}.""" - self.failUnlessEqual(_subst_vars('thing{{stuffvar}', {'{stuffvar': 'stuff'}), 'thingstuff') + def test_nested_var_substitution(self): + """Assert that the {curly brace token} expansion pattern will replace + only the inner {something} on nested expressions like {py{something}} on + the first pass. + + We have no plans to make use of this, but it keeps the option open for + the future, at the cost only of disallowing { itself as a piece of a + substitution key (which would be weird). + + """ + self.failUnlessEqual(_subst_vars('{py{version}}', {'version': '31'}), '{py31}') def test_get_paths(self): scheme = get_paths() |
