Permalink
Browse files

init

  • Loading branch information...
0 parents commit 983c3ea7430040e6c7768f0819b60723ddc25c6e @timbertson committed Jul 24, 2010
Showing with 89 additions and 0 deletions.
  1. +1 −0 VERSION
  2. +73 −0 version
  3. +15 −0 version.xml
@@ -0,0 +1 @@
+0.1
73 version
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+
+import sys, os
+import re
+import traceback
+VERBOSE=False
+
+def version_file(val=None):
+ v = "VERSION"
+ if os.path.exists(v):
+ if val is None:
+ with open(v) as f:
+ return f.read().strip()
+ else:
+ with open(v, 'w') as f:
+ f.write(val)
+ return True
+version_file.desc = "VERSION"
+
+def setup_py(val=None):
+ s = "setup.py"
+ if os.path.exists(s):
+ version_re = re.compile("""(?P<pre>version\s*=\s*['"])(?P<version>[^'"]*)""")
+ with open(s) as f:
+ lines = f.read()
+ lines = open(s).read()
+ if val is None:
+ return re.search(version_re, lines).group('version')
+ else:
+ with open(s, 'w') as f:
+ f.write(re.sub(version_re, r"\g<pre>%s" % (val,), lines, 1))
+ return True
+setup_py.desc = "setup.py"
+
+version_strategies = [setup_py, version_file]
+def version_types(*a):
+ def do(strategy):
+ try:
+ return strategy(*a)
+ except StandardError, e:
+ print >> sys.stderr, "[ error: %s (%s)]" % (e,strategy.desc)
+ if VERBOSE:
+ traceback.print_exc(file=sys.stderr)
+ results = [(do(s), s.desc) for s in version_strategies]
+ return [r for r in results if r[0] is not None]
+
+def main(args):
+ if len(args) > 1 or '--help' in args:
+ print >> sys.stderr, "Usage: %s [version]" % (os.path.basename(sys.argv[0]),)
+ sys.exit(1)
+ versions = version_types()
+ for version in versions:
+ print "%-8s (%s)" % version
+ if len(args) == 1:
+ new_version = args[0]
+ ok = raw_input("\nchange version to %s? " % (new_version,)).strip().lower() in ('y','yes','')
+ if not ok:
+ sys.exit(0)
+ changed = version_types(args[0])
+ print "changed version in %s files." % (len(changed),)
+
+if __name__ == '__main__':
+ sys_argv = sys.argv[1:]
+ argv = [arg for arg in sys_argv if arg not in ('-v',)]
+ if '-v' in sys_argv:
+ VERBOSE=True
+ try:
+ main(argv)
+ except StandardError, e:
+ print >> sys.stderr, e
+ if VERBOSE: raise
+ except (KeyboardInterrupt, EOFError):
+ print ""
@@ -0,0 +1,15 @@
+<?xml version="1.0" ?>
+<?xml-stylesheet type='text/xsl' href='interface.xsl'?>
+<interface uri="http://gfxmonk.net/dist/0install/version.xml" xmlns="http://zero-install.sourceforge.net/2004/injector/interface">
+ <name>version</name>
+ <summary>view (and modify) your project version in multiple commonly-used places</summary>
+ <description>
+ </description>
+ <group main="version">
+ <implementation id="sha1new=fd922b49210b8a26f2db866640a29c76cd208efb" released="2010-07-24" version="0.1">
+
+ <manifest-digest sha256="3e98d76fc60324eeae6eca480270595e59c32fa00a1b6d409de316f0fb2f46f5"/>
+ <archive href="http://gfxmonk.net/dist/0install/version/version-0.1.tgz" size="961"/>
+ </implementation>
+ </group>
+</interface>

0 comments on commit 983c3ea

Please sign in to comment.