(error_container, index_name, total_count)
return (
        '{0:d} out of {1:d} events imported. Most common error type '
        'is "{2:s}" with the detail of "{3:s}"').format(
            total_count - error_count, total_count,
            top_type, top_details)
Returns a string with error message or an empty string if no errors.

    Args:
      error_container: dict with error messages for each index.
      index_name: string with the search index name.
      total_count: integer with the total amount of events indexed.
Returns a string with error message or an empty string if no errors.
Returns a string with error message or an empty string if no errors .
def get_import_errors(error_container, index_name, total_count):
    """Returns a string with error message or an empty string if no errors.

    Args:
      error_container: dict with error messages for each index.
      index_name: string with the search index name.
      total_count: integer with the total amount of events indexed.
    """
    if index_name not in error_container:
        return ''

    index_dict = error_container[index_name]
    error_list = index_dict.get('errors', [])

    if not error_list:
        return ''

    error_count = len(error_list)

    error_types = index_dict.get('types')
    error_details = index_dict.get('details')

    if error_types:
        top_type = error_types.most_common()[0][0]
    else:
        top_type = 'Unknown Reasons'

    if error_details:
        top_details = error_details.most_common()[0][0]
    else:
        top_details = 'Unknown Reasons'

    if total_count is None:
        total_count = 0

    if not top_type:
        top_type = 'Unknown Reasons'
    if not top_details:
        top_details = 'Unknown Reasons'

    return (
        '{0:d} out of {1:d} events imported. Most common error type '
        'is "{2:s}" with the detail of "{3:s}"').format(
            total_count - error_count, total_count,
            top_type, top_details)
def get_import_errors ( error_container , index_name , total_count ) : if index_name not in error_container : return '' index_dict = error_container [ index_name ] error_list = index_dict . get ( 'errors' , [ ] ) if not error_list : return '' error_count = len ( error_list ) error_types = index_dict . get ( 'types' ) error_details = index_dict . get ( 'details' ) if error_types : top_type = error_types . most_common ( ) [ 0 ] [ 0 ] else : top_type = 'Unknown Reasons' if error_details : top_details = error_details . most_common ( ) [ 0 ] [ 0 ] else : top_details = 'Unknown Reasons' if total_count is None : total_count = 0 if not top_type : top_type = 'Unknown Reasons' if not top_details : top_details = 'Unknown Reasons' return ( '{0:d} out of {1:d} events imported. Most common error type ' 'is "{2:s}" with the detail of "{3:s}"' ) . format ( total_count - error_count , total_count , top_type , top_details )