#!/usr/bin/env python

"""
Script for deploying a new version of the python-asana library.
"""

import argparse
import re
import subprocess
import sys

if __name__ == '__main__':
  parser = argparse.ArgumentParser()
  parser.add_argument(
    'version',
    help='Version to deploy as, in format x.y.z')
  args = parser.parse_args()

  if not re.match('[0-9]+[.][0-9]+[.][0-9]+', args.version):
    print 'Invalid version: %s' % args.version
    sys.exit(1)

  version_file = open('asana/version.py', 'w')
  print >>version_file, "VERSION = '%s'" % args.version
  subprocess.call(
    'git commit -a -m "Releasing version %s"' % args.version, shell=True)
  subprocess.call(
    'git tag %s' % args.version, shell=True)
  subprocess.call(
    'git push --tags origin master:master', shell=True)
  print 'Successfully deployed version %s' % args.version

@@ -505,16 +505,8 @@
 )%0A  
-print %3E%3E
 vers
@@ -513,18 +513,23 @@
 ion_file
-, 
+.write(
 %22VERSION
@@ -535,16 +535,18 @@
 N = '%25s'
+%5Cn
 %22 %25 args
@@ -553,16 +553,41 @@
 .version
+)%0A  version_file.close()%0A
 %0A  subpr
@@ -618,11 +618,8 @@
 mit 
--a 
 -m %22
@@ -639,16 +639,33 @@
 sion %25s%22
+ asana/version.py
 ' %25 args

Fix deploy.py version writing