From 076e9e5be20a104e8d8882235f188f98a38dea89 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Wed, 6 Feb 2013 13:18:01 +1100 Subject: 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 --- openstack/common/version.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'openstack') 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.""" -- cgit