Skip to content

Commit

Permalink
ignore failure when setup.py has no version declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
gfxmonk committed Jan 5, 2011
1 parent 8f52b72 commit a97a0f9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions version.py
Expand Up @@ -26,9 +26,10 @@ def replace(filename, regex, val):
return None
with open(filename) as f:
lines = f.read()
match = re.search(regex, lines)
if val is None:
return re.search(regex, lines).group('version')
else:
return match.group('version') if match else None
elif match:
with open(filename, 'w') as f:
f.write(re.sub(regex, r"\g<pre>%s" % (val,), lines))
return True
Expand Down Expand Up @@ -234,12 +235,13 @@ def split_suffix(part):
if __name__ == '__main__':
import optparse
p = optparse.OptionParser(usage="%prog [OPTIONS] [version]")
p.add_option('-v', '--verbose', help="print more debugging info")
p.add_option('-v', '--verbose', action='store_true', help="print more debugging info", default=False)
p.add_option('--pre', dest='suffix', help="set -pre suffix")
p.add_option('--rc', dest='suffix', help="set -rc suffix")
p.add_option('--post', dest='suffix', help="set -post suffix")

opts, args = p.parse_args()
VERBOSE = opts.verbose

try:
main(opts, *args)
Expand Down

0 comments on commit a97a0f9

Please sign in to comment.