spack/lib/spack
Todd Gamblin 96ddbd5e17
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>
2024-08-01 18:20:43 -06:00
..
docs build(deps): bump pytest from 8.2.2 to 8.3.1 in /lib/spack/docs (#45377) 2024-07-23 11:53:55 -04:00
env ldflags=* are compiler flags, not linker flags (#43820) 2024-04-26 09:19:03 +02:00
external Update vendored archspec to v0.2.4 (#44005) 2024-05-06 10:20:56 +02:00
llnl Fix bug in logfile parsing (#42706) 2024-06-27 07:07:30 -06:00
spack format: allow spaces in format specifiers (#45487) 2024-08-01 18:20:43 -06:00
spack_installable Update copyright year to 2024 (#41919) 2024-01-02 09:21:30 +01:00