summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2017-04-26 11:06:34 -0700
committerGitHub <noreply@github.com>2017-04-26 11:06:34 -0700
commitb3ba9bdb377728bb4886dbc4ae11ac3a57a59bae (patch)
tree207bb4a234ec18db16355deae0c32bcbcd0ba5f5 /lib
parentc616e4a61904119a5a396a822634ffb1b8326f33 (diff)
downloadspack-b3ba9bdb377728bb4886dbc4ae11ac3a57a59bae.tar.gz
spack-b3ba9bdb377728bb4886dbc4ae11ac3a57a59bae.tar.bz2
spack-b3ba9bdb377728bb4886dbc4ae11ac3a57a59bae.tar.xz
spack-b3ba9bdb377728bb4886dbc4ae11ac3a57a59bae.zip
Add __format__ support to version for fancy formatting. (#3996)
- add Version.__format__ to support new-style formatting. - Python3 doesn't handle this well -- it delegates to object.__format__(), which raises an error for fancy format strings. - not sure why it doesn't call str(self).__format__ instead, but that's hwo things are.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/version.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/spack/spack/version.py b/lib/spack/spack/version.py
index 89fcc9aaa7..1c931ae90a 100644
--- a/lib/spack/spack/version.py
+++ b/lib/spack/spack/version.py
@@ -226,6 +226,9 @@ class Version(object):
def __str__(self):
return self.string
+ def __format__(self, format_spec):
+ return self.string.format(format_spec)
+
@property
def concrete(self):
return self