diff options
| author | Monty Taylor <mordred@inaugust.com> | 2013-02-06 13:18:01 +1100 |
|---|---|---|
| committer | Monty Taylor <mordred@inaugust.com> | 2013-02-07 06:22:21 -0600 |
| commit | 076e9e5be20a104e8d8882235f188f98a38dea89 (patch) | |
| tree | 846c9c725073c30f123526361f9693c553763125 /openstack | |
| parent | 50eae15777327745b2d87069922bf32c4f6f397c (diff) | |
| download | oslo-076e9e5be20a104e8d8882235f188f98a38dea89.tar.gz oslo-076e9e5be20a104e8d8882235f188f98a38dea89.tar.xz oslo-076e9e5be20a104e8d8882235f188f98a38dea89.zip | |
Add support for directly stringifying VersionInfo.
glanceclient, and others, want to have a __version__ member in their
top-level __init__.py. This leads to attempting to process the
version information to realize the string at import time, rather
than at request time. If we make VersionInfo a thing which can
behave like a string, then, we should get the things we want without
the operational weirdness.
Change-Id: I3eb15006f50ed1155c85977aaae842677c5ec4bc
Diffstat (limited to 'openstack')
| -rw-r--r-- | openstack/common/version.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/openstack/common/version.py b/openstack/common/version.py index c27095a..1a15645 100644 --- a/openstack/common/version.py +++ b/openstack/common/version.py @@ -33,6 +33,14 @@ class VersionInfo(object): self.version = None self._cached_version = None + def __str__(self): + """Make the VersionInfo object behave like a string.""" + return self.version_string() + + def __repr__(self): + """Include the name.""" + return "VersionInfo(%s:%s)" % (self.package, self.version_string()) + def _get_version_from_pkg_resources(self): """Get the version of the package from the pkg_resources record associated with the package.""" |
