Permalink
Browse files

ignore failure when setup.py has no version declaration

  • Loading branch information...
1 parent 8f52b72 commit a97a0f9bcb23c119de5a7bed10d7add5cd5546b8 @timbertson committed Jan 5, 2011
Showing with 5 additions and 3 deletions.
  1. +5 −3 version.py
View
@@ -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
@@ -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)

0 comments on commit a97a0f9

Please sign in to comment.