<s> import os <EOL> import re <EOL> import subprocess <EOL> import sys <EOL> from distutils . version import StrictVersion <EOL> PROJECT_DIRECTORY = os . path . join ( os . path . dirname ( __file__ ) , "<STR_LIT:..>" ) <EOL> def main ( argv ) : <EOL> source_dir = argv [ <NUM_LIT:1> ] <EOL> old_version = StrictVersion ( argv [ <NUM_LIT:2> ] ) <EOL> old_version_tuple = old_version . version <EOL> new_version_tuple = list ( old_version_tuple ) <EOL> new_version_tuple [ <NUM_LIT:1> ] = old_version_tuple [ <NUM_LIT:1> ] + <NUM_LIT:1> <EOL> new_version_tuple [ <NUM_LIT:2> ] = <NUM_LIT:0> <EOL> new_version = "<STR_LIT:.>" . join ( map ( str , new_version_tuple ) ) <EOL> history_path = os . path . join ( PROJECT_DIRECTORY , "<STR_LIT>" ) <EOL> history = open ( history_path , "<STR_LIT:r>" ) . read ( ) <EOL> def extend ( from_str , line ) : <EOL> from_str += "<STR_LIT:\n>" <EOL> return history . replace ( from_str , from_str + line + "<STR_LIT:\n>" ) <EOL> history = extend ( "<STR_LIT>" , """<STR_LIT>""" % new_version ) <EOL> open ( history_path , "<STR_LIT:w>" ) . write ( history ) <EOL> planemo_mod_path = os . path . join ( PROJECT_DIRECTORY , source_dir , "<STR_LIT>" ) <EOL> mod = open ( planemo_mod_path , "<STR_LIT:r>" ) . read ( ) <EOL> mod = re . sub ( "<STR_LIT>" , <EOL> "<STR_LIT>" % new_version , <EOL> mod , <NUM_LIT:1> ) <EOL> mod = open ( planemo_mod_path , "<STR_LIT:w>" ) . write ( mod ) <EOL> shell ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" % new_version , <EOL> "<STR_LIT>" , "<STR_LIT>" % source_dir ] ) <EOL> def shell ( cmds , ** kwds ) : <EOL> p = subprocess . Popen ( cmds , ** kwds ) <EOL> return p . wait ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( sys . argv ) </s>
