diff options
| author | Monty Taylor <mordred@inaugust.com> | 2012-06-26 21:06:04 -0500 |
|---|---|---|
| committer | Monty Taylor <mordred@inaugust.com> | 2012-06-26 21:06:04 -0500 |
| commit | 89e21b6b30a1d3597c7e90ee87080439a8a8ec31 (patch) | |
| tree | bf3aaf3106d532cea9e791f755230cdc87286fba /openstackclient | |
| parent | 99586e05d7f70e0adb2eddaff7f079ec04b464fd (diff) | |
| download | python-openstackclient-89e21b6b30a1d3597c7e90ee87080439a8a8ec31.tar.gz | |
Add read_versioninfo method.
Change-Id: Iba12b260a30cc1311967a833e26eaeb9bf3afb47
Diffstat (limited to 'openstackclient')
| -rw-r--r-- | openstackclient/openstack/common/setup.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/openstackclient/openstack/common/setup.py b/openstackclient/openstack/common/setup.py index e9cd3400..caf06fa5 100644 --- a/openstackclient/openstack/common/setup.py +++ b/openstackclient/openstack/common/setup.py @@ -205,6 +205,20 @@ _rst_template = """%(heading)s """ +def read_versioninfo(project): + """Read the versioninfo file. If it doesn't exist, we're in a github + zipball, and there's really know way to know what version we really + are, but that should be ok, because the utility of that should be + just about nil if this code path is in use in the first place.""" + versioninfo_path = os.path.join(project, 'versioninfo') + if os.path.exists(versioninfo_path): + with open(versioninfo_path, 'r') as vinfo: + version = vinfo.read().strip() + else: + version = "0.0.0" + return version + + def write_versioninfo(project, version): """Write a simple file containing the version of the package.""" open(os.path.join(project, 'versioninfo'), 'w').write("%s\n" % version) @@ -312,9 +326,8 @@ def get_pre_version(projectname, base_version): write_versioninfo(projectname, version) return version.split('~')[0] else: - with open(os.path.join(projectname, 'versioninfo'), 'r') as vinfo: - full_version = vinfo.read().strip() - return full_version.split('~')[0] + version = read_versioninfo(projectname) + return version.split('~')[0] def get_post_version(projectname): @@ -326,4 +339,4 @@ def get_post_version(projectname): version = _get_git_post_version() write_versioninfo(projectname, version) return version - return open(os.path.join(projectname, 'versioninfo'), 'r').read().strip() + return read_versioninfo(projectname) |
