release.py: Fix bumping setup.py version

This commit is contained in:
Adrian Sampson 2014-09-19 11:05:18 -07:00
parent 6ac568c11b
commit dcc63e9824

View file

@ -55,7 +55,7 @@ VERSION_LOCS = [
os.path.join(BASE, 'setup.py'),
[
(
r'version\s*=\s*[\'"]([0-9\.]+)[\'"]',
r'\s*version\s*=\s*[\'"]([0-9\.]+)[\'"]',
" version='{version}',",
)
]
@ -77,6 +77,7 @@ def bump_version(version):
# Read and transform the file.
out_lines = []
with open(filename) as f:
found = False
for line in f:
for pattern, template in locations:
match = re.match(pattern, line)
@ -96,12 +97,16 @@ def bump_version(version):
minor=minor,
) + '\n')
found = True
break
else:
# Normal line.
out_lines.append(line)
if not found:
print("No pattern found in {}".format(filename))
# Write the file back.
with open(filename, 'w') as f:
f.write(''.join(out_lines))