#NEWLINE# def _append_module_field( yaml_text , yaml_dict , module_name , field_name , new_val ) : #NEWLINE# #INDENT# module_fields = yaml_dict [ module_name ] #NEWLINE# assert ( len ( module_fields ) > 0 ) , "There aren't any fields here!" #NEWLINE# last_key = module_fields . keys [ ( - 1 ) ] #NEWLINE# last_val = module_fields . vals [ ( - 1 ) ] #NEWLINE# indentation = ( ' ' * last_key . start_mark . column ) #NEWLINE# yaml_lines = yaml_text . split ( '\n' ) #NEWLINE# if ( last_val . end_mark . column > 0 ) : #NEWLINE# #INDENT# new_line_number = ( last_val . end_mark . line + 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# new_line_number = last_val . end_mark . line #NEWLINE# prev_line = new_line [ ( new_line_number - 1 ) ] #NEWLINE# if ( ( prev_line == '' ) or prev_line . isspace ( ) ) : #NEWLINE# #INDENT# new_line_number -= 1 #NEWLINE# #UNINDENT# #UNINDENT# new_line = '{}{}: {}' . format ( indentation , field_name , new_val ) #NEWLINE# new_yaml_lines = ( ( yaml_lines [ : new_line_number ] + [ new_line ] ) + yaml_lines [ new_line_number : ] ) #NEWLINE# return '\n' . join ( new_yaml_lines )