summaryrefslogtreecommitdiffstats
path: root/openstack/common
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2013-02-06 13:18:01 +1100
committerMonty Taylor <mordred@inaugust.com>2013-02-07 06:22:21 -0600
commit076e9e5be20a104e8d8882235f188f98a38dea89 (patch)
tree846c9c725073c30f123526361f9693c553763125 /openstack/common
parent50eae15777327745b2d87069922bf32c4f6f397c (diff)
downloadoslo-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/common')
-rw-r--r--openstack/common/version.py8
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."""