#NEWLINE# @ task #NEWLINE# def patch_version( vs , path = pjoin ( here , '..' ) ) : #NEWLINE# #INDENT# 'Patch zmq/sugar/version.py for the current release' #NEWLINE# v = parse_vs ( vs ) #NEWLINE# version_py = pjoin ( path , 'jupyterhub' , 'version.py' ) #NEWLINE# print ( ( 'patching %s with %s' % ( version_py , vs ) ) ) #NEWLINE# with open ( version_py ) as f : #NEWLINE# #INDENT# pre_lines = [ ] #NEWLINE# post_lines = [ ] #NEWLINE# for line in f : #NEWLINE# #INDENT# pre_lines . append ( line ) #NEWLINE# if line . startswith ( 'version_info' ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# for line in f : #NEWLINE# #INDENT# if line . startswith ( ')' ) : #NEWLINE# #INDENT# post_lines . append ( line ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# for line in f : #NEWLINE# #INDENT# post_lines . append ( line ) #NEWLINE# #UNINDENT# #UNINDENT# with open ( version_py , 'w' ) as f : #NEWLINE# #INDENT# for line in pre_lines : #NEWLINE# #INDENT# f . write ( line ) #NEWLINE# #UNINDENT# for part in v : #NEWLINE# #INDENT# f . write ( ( '    %r,\n' % part ) ) #NEWLINE# #UNINDENT# for line in post_lines : #NEWLINE# #INDENT# f . write ( line ) #NEWLINE# #UNINDENT# #UNINDENT# ns = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# with open ( version_py ) as f : #NEWLINE# #INDENT# exec ( f . read ( ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , ns ) #NEWLINE# #UNINDENT# assert ( ns [ '__version__' ] == vs ) , ( '%r != %r' % ( ns [ '__version__' ] , vs ) )