<s> import logging <EOL> import os <EOL> from awscli . customizations . configure . writer import ConfigFileWriter <EOL> from awscli . customizations . emr . constants import EC2_ROLE_NAME <EOL> from awscli . customizations . emr . constants import EMR_ROLE_NAME <EOL> LOG = logging . getLogger ( __name__ ) <EOL> def get_configs ( session ) : <EOL> return session . get_scoped_config ( ) . get ( '<STR_LIT>' , { } ) <EOL> def get_current_profile_name ( session ) : <EOL> profile_name = session . get_config_variable ( '<STR_LIT>' ) <EOL> return '<STR_LIT:default>' if profile_name is None else profile_name <EOL> def get_current_profile_var_name ( session ) : <EOL> return _get_profile_str ( session , '<STR_LIT:.>' ) <EOL> def _get_profile_str ( session , separator ) : <EOL> profile_name = session . get_config_variable ( '<STR_LIT>' ) <EOL> return '<STR_LIT:default>' if profile_name is None else '<STR_LIT>' % ( separator , profile_name ) <EOL> def is_any_role_configured ( session ) : <EOL> parsed_configs = get_configs ( session ) <EOL> return True if ( '<STR_LIT>' in parsed_configs or <EOL> '<STR_LIT>' in parsed_configs ) else False <EOL> def update_roles ( session ) : <EOL> if is_any_role_configured ( session ) : <EOL> LOG . debug ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> else : <EOL> config_writer = ConfigWriter ( session ) <EOL> config_writer . update_config ( '<STR_LIT>' , EMR_ROLE_NAME ) <EOL> config_writer . update_config ( '<STR_LIT>' , EC2_ROLE_NAME ) <EOL> LOG . debug ( "<STR_LIT>" ) <EOL> class ConfigWriter ( object ) : <EOL> def __init__ ( self , session ) : <EOL> self . session = session <EOL> self . section = _get_profile_str ( session , '<STR_LIT:U+0020>' ) <EOL> self . config_file_writer = ConfigFileWriter ( ) <EOL> def update_config ( self , key , value ) : <EOL> config_filename = os . path . expanduser ( self . session . get_config_variable ( '<STR_LIT>' ) ) <EOL> updated_config = { '<STR_LIT>' : self . section , <EOL> '<STR_LIT>' : { key : value } } <EOL> self . config_file_writer . update_config ( updated_config , config_filename ) </s>
