<s> from __future__ import print_function <EOL> import re <EOL> import ast <EOL> import subprocess <EOL> import sys <EOL> from optparse import OptionParser <EOL> DEBUG = False <EOL> CONFIRM_STEPS = False <EOL> DRY_RUN = False <EOL> def skip_step ( ) : <EOL> """<STR_LIT>""" <EOL> global CONFIRM_STEPS <EOL> if CONFIRM_STEPS : <EOL> choice = raw_input ( "<STR_LIT>" ) <EOL> if choice . lower ( ) == '<STR_LIT:n>' : <EOL> return True <EOL> return False <EOL> def run_step ( * args ) : <EOL> """<STR_LIT>""" <EOL> global DRY_RUN <EOL> cmd = args <EOL> print ( '<STR_LIT:U+0020>' . join ( cmd ) ) <EOL> if skip_step ( ) : <EOL> print ( '<STR_LIT>' ) <EOL> elif DRY_RUN : <EOL> print ( '<STR_LIT>' ) <EOL> else : <EOL> subprocess . check_output ( cmd ) <EOL> def version ( version_file ) : <EOL> _version_re = re . compile ( r'<STR_LIT>' ) <EOL> with open ( version_file , '<STR_LIT:rb>' ) as f : <EOL> ver = str ( ast . literal_eval ( _version_re . search ( <EOL> f . read ( ) . decode ( '<STR_LIT:utf-8>' ) ) . group ( <NUM_LIT:1> ) ) ) <EOL> return ver <EOL> def commit_for_release ( version_file , ver ) : <EOL> run_step ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> run_step ( '<STR_LIT>' , '<STR_LIT>' , version_file ) <EOL> run_step ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' % ver ) <EOL> def create_git_tag ( tag_name ) : <EOL> run_step ( '<STR_LIT>' , '<STR_LIT>' , tag_name ) <EOL> def register_with_pypi ( ) : <EOL> run_step ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def create_source_tarball ( ) : <EOL> run_step ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def push_to_github ( ) : <EOL> run_step ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def push_tags_to_github ( ) : <EOL> run_step ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def checklist ( questions ) : <EOL> for question in questions : <EOL> choice = raw_input ( question + '<STR_LIT>' ) <EOL> if choice . lower ( ) != '<STR_LIT:y>' : <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> if DEBUG : <EOL> subprocess . check_output = lambda x : x <EOL> checks = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> checklist ( checks ) <EOL> ver = version ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' , ver ) <EOL> parser = OptionParser ( ) <EOL> parser . add_option ( <EOL> "<STR_LIT:-c>" , "<STR_LIT>" , action = "<STR_LIT:store_true>" , dest = "<STR_LIT>" , <EOL> default = False , help = ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> ) <EOL> parser . add_option ( <EOL> "<STR_LIT>" , "<STR_LIT>" , action = "<STR_LIT:store_true>" , dest = "<STR_LIT>" , <EOL> default = False , help = "<STR_LIT>" <EOL> ) <EOL> popts , pargs = parser . parse_args ( ) <EOL> CONFIRM_STEPS = popts . confirm_steps <EOL> DRY_RUN = popts . dry_run <EOL> choice = raw_input ( '<STR_LIT>' ) <EOL> if choice . lower ( ) != '<STR_LIT:y>' : <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> commit_for_release ( '<STR_LIT>' , ver ) <EOL> create_git_tag ( '<STR_LIT>' % ver ) <EOL> register_with_pypi ( ) <EOL> create_source_tarball ( ) <EOL> push_to_github ( ) <EOL> push_tags_to_github ( ) </s>
