diff options
| author | Monty Taylor <mordred@inaugust.com> | 2012-06-26 14:18:00 -0500 |
|---|---|---|
| committer | Monty Taylor <mordred@inaugust.com> | 2012-06-26 21:07:18 -0500 |
| commit | ae2c6f0c93a1c1bdb2dd503978ef912547114f55 (patch) | |
| tree | 6d61336ced613e2d97f97e5246d0c849eb6f06c0 /openstack | |
| parent | 71cddc514ac194e2332817673ef76c099dc158cc (diff) | |
| download | oslo-ae2c6f0c93a1c1bdb2dd503978ef912547114f55.tar.gz oslo-ae2c6f0c93a1c1bdb2dd503978ef912547114f55.tar.xz oslo-ae2c6f0c93a1c1bdb2dd503978ef912547114f55.zip | |
Split read_versioninfo into a method.
Change-Id: Iec1f9776b6e6fcccdc21b2e67754fff1da23458a
Diffstat (limited to 'openstack')
| -rw-r--r-- | openstack/common/setup.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/openstack/common/setup.py b/openstack/common/setup.py index e9cd340..59c8049 100644 --- a/openstack/common/setup.py +++ b/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 no 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) |
