summaryrefslogtreecommitdiff
path: root/versioneer.py
diff options
context:
space:
mode:
authorjakobjakobson13 <43045863+jakobjakobson13@users.noreply.github.com>2021-07-09 15:19:24 +0200
committerGitHub <noreply@github.com>2021-07-09 15:19:24 +0200
commitaaa9214bd463d5e06064fd95316399f4f00340b8 (patch)
treebda309d2b8fd23f8eba779f52cb6e612be4d0296 /versioneer.py
parent702c5f5c5fcb0e96e3a3429abf21e3f2c9bd2170 (diff)
downloadnumpy-aaa9214bd463d5e06064fd95316399f4f00340b8.tar.gz
Update versioneer.py
Diffstat (limited to 'versioneer.py')
-rw-r--r--versioneer.py45
1 files changed, 21 insertions, 24 deletions
diff --git a/versioneer.py b/versioneer.py
index 7a77c5ef7..7aa415ac8 100644
--- a/versioneer.py
+++ b/versioneer.py
@@ -946,21 +946,20 @@ def git_get_keywords(versionfile_abs):
# _version.py.
keywords = {}
try:
- f = open(versionfile_abs, "r")
- for line in f.readlines():
- if line.strip().startswith("git_refnames ="):
- mo = re.search(r'=\s*"(.*)"', line)
- if mo:
- keywords["refnames"] = mo.group(1)
- if line.strip().startswith("git_full ="):
- mo = re.search(r'=\s*"(.*)"', line)
- if mo:
- keywords["full"] = mo.group(1)
- if line.strip().startswith("git_date ="):
- mo = re.search(r'=\s*"(.*)"', line)
- if mo:
- keywords["date"] = mo.group(1)
- f.close()
+ with open(versionfile_abs, "r") as f:
+ for line in f.readlines():
+ if line.strip().startswith("git_refnames ="):
+ mo = re.search(r'=\s*"(.*)"', line)
+ if mo:
+ keywords["refnames"] = mo.group(1)
+ if line.strip().startswith("git_full ="):
+ mo = re.search(r'=\s*"(.*)"', line)
+ if mo:
+ keywords["full"] = mo.group(1)
+ if line.strip().startswith("git_date ="):
+ mo = re.search(r'=\s*"(.*)"', line)
+ if mo:
+ keywords["date"] = mo.group(1)
except EnvironmentError:
pass
return keywords
@@ -1142,18 +1141,16 @@ def do_vcs_install(manifest_in, versionfile_source, ipy):
files.append(versioneer_file)
present = False
try:
- f = open(".gitattributes", "r")
- for line in f.readlines():
- if line.strip().startswith(versionfile_source):
- if "export-subst" in line.strip().split()[1:]:
- present = True
- f.close()
+ with open(".gitattributes", "r") as f:
+ for line in f.readlines():
+ if line.strip().startswith(versionfile_source):
+ if "export-subst" in line.strip().split()[1:]:
+ present = True
except EnvironmentError:
pass
if not present:
- f = open(".gitattributes", "a+")
- f.write("%s export-subst\n" % versionfile_source)
- f.close()
+ with open(".gitattributes", "a+") as f:
+ f.write("%s export-subst\n" % versionfile_source)
files.append(".gitattributes")
run_command(GITS, ["add", "--"] + files)