<s> """<STR_LIT>""" <EOL> import sys , os <EOL> import re <EOL> import argparse <EOL> import ConfigParser <EOL> from os . path import expanduser <EOL> parser = argparse . ArgumentParser ( description = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store>' , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store>' , <EOL> help = '<STR_LIT>' ) <EOL> args = parser . parse_args ( ) <EOL> if args . config_section : <EOL> section_name = args . config_section <EOL> section_name_pretty = args . config_section <EOL> if not args . config_section or args . config_section . lower ( ) == "<STR_LIT:default>" : <EOL> section_name = "<STR_LIT>" <EOL> section_name_pretty = "<STR_LIT:default>" <EOL> print "<STR_LIT>" <EOL> print <EOL> print "<STR_LIT>" % section_name_pretty <EOL> print <EOL> if args . cred_file : <EOL> print "<STR_LIT>" , args . cred_file <EOL> with open ( os . path . expanduser ( args . cred_file ) , "<STR_LIT:r>" ) as credFile : <EOL> text = credFile . read ( ) <EOL> credFile . close ( ) <EOL> else : <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print <EOL> sys . stdout . write ( '<STR_LIT>' ) <EOL> text = sys . stdin . read ( ) <EOL> sys . stdout . write ( '<STR_LIT>' ) <EOL> home = expanduser ( "<STR_LIT>" ) <EOL> fieldlist = text . split ( ) <EOL> index = <NUM_LIT:0> <EOL> fields = { } <EOL> while index < len ( fieldlist ) : <EOL> if ( re . search ( r'<STR_LIT>' , fieldlist [ index ] ) ) : <EOL> fields [ fieldlist [ index ] ] = fieldlist [ index + <NUM_LIT:1> ] <EOL> index += <NUM_LIT:1> <EOL> origConfig = ConfigParser . ConfigParser ( ) <EOL> filename = "<STR_LIT>" % home <EOL> if not os . path . isfile ( filename ) : <EOL> print "<STR_LIT>" % filename <EOL> open ( filename , '<STR_LIT>' ) . close ( ) <EOL> else : <EOL> print "<STR_LIT>" % filename <EOL> origConfig . read ( filename ) <EOL> if section_name_pretty not in origConfig . sections ( ) : <EOL> print "<STR_LIT>" % section_name_pretty <EOL> replace_section = True <EOL> else : <EOL> print "<STR_LIT>" % section_name_pretty <EOL> replace_section = False <EOL> print <EOL> with open ( filename , "<STR_LIT>" ) as myfile : <EOL> data = myfile . read ( ) . replace ( '<STR_LIT:default>' , '<STR_LIT>' ) <EOL> myfile . close ( ) <EOL> with open ( filename , "<STR_LIT:w>" ) as myfile : <EOL> myfile . write ( data ) <EOL> myfile . close ( ) <EOL> Config = ConfigParser . ConfigParser ( ) <EOL> Config . read ( filename ) <EOL> configfile = open ( filename , '<STR_LIT:w>' ) <EOL> if not Config . has_section ( section_name ) : <EOL> Config . add_section ( section_name ) <EOL> Config . set ( section_name , '<STR_LIT>' , fields [ '<STR_LIT>' ] ) <EOL> Config . set ( section_name , '<STR_LIT:host>' , fields [ '<STR_LIT>' ] . replace ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> Config . set ( section_name , '<STR_LIT>' , fields [ '<STR_LIT>' ] ) <EOL> Config . set ( section_name , '<STR_LIT>' , fields [ '<STR_LIT>' ] ) <EOL> Config . set ( section_name , '<STR_LIT>' , <NUM_LIT> ) <EOL> Config . write ( configfile ) <EOL> configfile . close ( ) <EOL> with open ( filename , "<STR_LIT:r>" ) as myfile : <EOL> data = myfile . read ( ) . replace ( '<STR_LIT>' , '<STR_LIT:default>' ) <EOL> myfile . close ( ) <EOL> with open ( filename , "<STR_LIT:w>" ) as myfile : <EOL> myfile . write ( data ) <EOL> myfile . close ( ) <EOL> print "<STR_LIT>" % section_name_pretty <EOL> print </s>
