diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2024-08-01 17:20:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-01 18:20:43 -0600 |
commit | 96ddbd5e17a200dd3f78e6d4f6aff287d96d9e31 (patch) | |
tree | 273769053be79e89765866eec25d6e889887b0e2 /.flake8 | |
parent | 65b530e7ece99a3827d131f789e2864e538ca3cf (diff) | |
download | spack-96ddbd5e17a200dd3f78e6d4f6aff287d96d9e31.tar.gz spack-96ddbd5e17a200dd3f78e6d4f6aff287d96d9e31.tar.bz2 spack-96ddbd5e17a200dd3f78e6d4f6aff287d96d9e31.tar.xz spack-96ddbd5e17a200dd3f78e6d4f6aff287d96d9e31.zip |
format: allow spaces in format specifiers (#45487)
* format: allow spaces in format specifiers
Key-value pair format specifiers can now contain spaces in the key. This allows us to
add spaces to format strings that are *only* present when the attribute formatted is not
``None``. Instead of writing:
```
{arch=architecture}
```
and special casing `arch=` like a sigil in `Spec.format()`, we can now write:
```
{ arch=architecture}
```
And the space is *only* printed when `architecture` is not `None`. This allows us to
remove the special case in `Spec.format()` for `arch=`.
Previously the only `key=` prefix allowed in format specifiers was `arch=`, but this PR
removes that requirement, and the `key=` part of a key-value specifier can be any name.
It does *not* have to correspond to the formatted attribute.
- [x] modify `SPEC_FORMAT_RE` to allow arbitrary keys in key-value pairs.
- [x] remove special case for `arch=` from `Spec.format()`.
- [x] modify format strings using `{arch=architecture}` to use `{ arch=architecture}`
- [x] add more tests for formatting
This PR saves other more complex attributes like compiler flags and their spacing for later.
Signed-off-by: Todd Gamblin <tgamblin@llnl.gov>
Diffstat (limited to '.flake8')
0 files changed, 0 insertions, 0 deletions