summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2012-07-14 10:05:06 -0700
committerMonty Taylor <mordred@inaugust.com>2012-07-15 09:02:12 -0700
commit85f1dccce192203b095f987127388975a288e774 (patch)
tree18390558a39abef264359d3ee03610f1f85f0495
parent91e19d68f5da564f1a38f0a25c831f24d5c867f2 (diff)
downloadpbr-85f1dccce192203b095f987127388975a288e774.tar.gz
Add support for deferred_version_string_with_vcs.
Change-Id: Ibeef9536da478f886ac422601ec24eb7824a9c3b
-rw-r--r--pbr/version.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/pbr/version.py b/pbr/version.py
index 9a676c1..d5f7880 100644
--- a/pbr/version.py
+++ b/pbr/version.py
@@ -138,15 +138,16 @@ def get_post_version(projectname):
class _deferred_version_string(object):
"""Internal helper class which provides delayed version calculation."""
- def __init__(self, version_info, prefix):
+ def __init__(self, version_info, version_method, prefix):
self.version_info = version_info
+ self.version_method = version_method
self.prefix = prefix
def __str__(self):
- return "%s%s" % (self.prefix, self.version_info.version_string())
+ return "%s%s" % (self.prefix, self.version_method(self_version_info))
def __repr__(self):
- return "%s%s" % (self.prefix, self.version_info.version_string())
+ return __str__(self)
class VersionInfo(object):
@@ -257,4 +258,15 @@ class VersionInfo(object):
passing version information into the CONF constructor, but
rather only do the calculation when and if a version is requested
"""
- return _deferred_version_string(self, prefix)
+ return _deferred_version_string(self, self.version_string, prefix)
+
+ def deferred_version_string_with_vcs(self, prefix=""):
+ """Generate an object which will expand in a string context to
+ the results of version_string(). We do this so that don't
+ call into pkg_resources every time we start up a program when
+ passing version information into the CONF constructor, but
+ rather only do the calculation when and if a version is requested
+ """
+ return _deferred_version_string_with_vcs(self,
+ self.version_string_with_vcs,
+ prefix)