diff options
author | Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de> | 2010-05-25 19:46:38 +0200 |
---|---|---|
committer | Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de> | 2010-05-25 19:46:38 +0200 |
commit | 1d639c83aa79e6df60ddb62f93719c47b76073b6 (patch) | |
tree | c7951e5b946a79061afc835cdc52090b58b559ec | |
parent | 77c2d208ba58f7c0219c51eeb61022bb04503471 (diff) | |
parent | 8a77ebac41661df7c92fd5540fad1085efa56599 (diff) | |
download | setuptools-scm-1d639c83aa79e6df60ddb62f93719c47b76073b6.tar.gz |
merge the old python support fork0.2
-rw-r--r-- | hgdistver.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/hgdistver.py b/hgdistver.py index f5a7f78..3cb1b3d 100644 --- a/hgdistver.py +++ b/hgdistver.py @@ -21,14 +21,18 @@ import os def version_from_cachefile(cachefile=None): if not cachefile: return - with open(cachefile) as fd: - fd.readline() # remove the comment - try: - line = fd.readline() - version_string = line.split(' = ')[1].strip() - return version_string[1:-1].decode('string-escape') - except: # any error means invalid cachefile - pass + #replaces 'with open()' from py2.6 + fd = open(cachefile) + fd.readline() # remove the comment + version = None + try: + line = fd.readline() + version_string = line.split(' = ')[1].strip() + version = version_string[1:-1].decode('string-escape') + except: # any error means invalid cachefile + pass + fd.close() + return version def version_from_hg_id(cachefile=None): |