Skip to content

Commit

Permalink
Update versioneer.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobjakobson13 authored Jul 9, 2021
1 parent 702c5f5 commit aaa9214
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions versioneer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit aaa9214

Please sign in to comment.