<s> import os <EOL> import re <EOL> import sys <EOL> import subprocess <EOL> VERSION_FILE = '<STR_LIT>' <EOL> def bump_version ( ) : <EOL> with open ( VERSION_FILE ) as f : <EOL> lines = f . read ( ) . splitlines ( ) <EOL> new_lines = f . newlines <EOL> for i , l in enumerate ( lines ) : <EOL> if '<STR_LIT>' in l : <EOL> string = l . split ( '<STR_LIT:=>' ) [ <NUM_LIT:1> ] . strip ( ) . replace ( '<STR_LIT:">' , '<STR_LIT>' ) . replace ( "<STR_LIT:'>" , '<STR_LIT>' ) <EOL> for prefix in [ '<STR_LIT>' , '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT>' ] : <EOL> try : <EOL> suffix = re . findall ( r'<STR_LIT>' % prefix , string ) [ <NUM_LIT:0> ] <EOL> except IndexError : <EOL> suffix = None <EOL> version = None <EOL> else : <EOL> version = int ( suffix . replace ( prefix , '<STR_LIT>' ) ) <EOL> break <EOL> if None in [ suffix , version ] : <EOL> return <EOL> version += <NUM_LIT:1> <EOL> new_suffix = '<STR_LIT>' % ( prefix , version ) <EOL> new_string = string . replace ( suffix , new_suffix ) <EOL> lines [ i ] = "<STR_LIT>" % new_string <EOL> print ( lines [ i ] ) <EOL> break <EOL> with open ( VERSION_FILE , '<STR_LIT:w>' ) as f : <EOL> f . write ( '<STR_LIT:\n>' . join ( lines ) ) <EOL> f . write ( '<STR_LIT:\n>' ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:w>' ) as f : <EOL> pass <EOL> bump_version ( ) </s>
