(file_or_filename, lang)
return sheet_name_to_unique_id
Returns a map of sheet names to unique IDs, so that when modules or
    forms have been moved we can use their ID and not their (changed) name.

    This function is called before we process the upload so that we can use
    the sheet-name-to-unique-ID map to check the sheets before they are
    processed.

    `file_or_filename` is a file not a workbook because we read uploaded
    Excel files using WorkbookJSONReader, and it can only iterate sheet
    rows once. This function opens its own Reader to parse the first sheet.
Returns a map of sheet names to unique IDs, so that when modules or
    forms have been moved we can use their ID and not their (changed) name.
Returns a map of sheet names to unique IDs so that when modules or forms have been moved we can use their ID and not their ( changed ) name .
def get_sheet_name_to_unique_id_map(file_or_filename, lang):
    """
    Returns a map of sheet names to unique IDs, so that when modules or
    forms have been moved we can use their ID and not their (changed) name.

    This function is called before we process the upload so that we can use
    the sheet-name-to-unique-ID map to check the sheets before they are
    processed.

    `file_or_filename` is a file not a workbook because we read uploaded
    Excel files using WorkbookJSONReader, and it can only iterate sheet
    rows once. This function opens its own Reader to parse the first sheet.
    """

    def get_sheet_name():
        return MODULES_AND_FORMS_SHEET_NAME if is_multisheet() else SINGLE_SHEET_NAME

    def is_multisheet():
        return not lang

    def is_modules_and_forms_row(row):
        """
        Returns the rows about modules and forms in single-sheet uploads.
        They are the rows that include the unique IDs.
        """
        return not row['case_property'] and not row['list_or_detail'] and not row['label']

    sheet_name_to_unique_id = {}

    try:
        worksheet = get_single_worksheet(file_or_filename, title=get_sheet_name())
    except WorkbookJSONError:
        # There is something wrong with the file. The problem will happen
        # again when we try to process the upload. To preserve current
        # behaviour, just return silently.
        return sheet_name_to_unique_id

    if is_multisheet():
        rows = worksheet
    else:
        rows = (row for row in worksheet if is_modules_and_forms_row(row))

    for row in get_unicode_dicts(rows):
        sheet_name = row.get('menu_or_form', '')
        unique_id = row.get('unique_id')
        if unique_id and sheet_name not in sheet_name_to_unique_id:
            sheet_name_to_unique_id[sheet_name] = unique_id
    return sheet_name_to_unique_id
def get_sheet_name_to_unique_id_map ( file_or_filename , lang ) : def get_sheet_name ( ) : return MODULES_AND_FORMS_SHEET_NAME if is_multisheet ( ) else SINGLE_SHEET_NAME def is_multisheet ( ) : return not lang def is_modules_and_forms_row ( row ) : """
        Returns the rows about modules and forms in single-sheet uploads.
        They are the rows that include the unique IDs.
        """ return not row [ 'case_property' ] and not row [ 'list_or_detail' ] and not row [ 'label' ] sheet_name_to_unique_id = { } try : worksheet = get_single_worksheet ( file_or_filename , title = get_sheet_name ( ) ) except WorkbookJSONError : # There is something wrong with the file. The problem will happen # again when we try to process the upload. To preserve current # behaviour, just return silently. return sheet_name_to_unique_id if is_multisheet ( ) : rows = worksheet else : rows = ( row for row in worksheet if is_modules_and_forms_row ( row ) ) for row in get_unicode_dicts ( rows ) : sheet_name = row . get ( 'menu_or_form' , '' ) unique_id = row . get ( 'unique_id' ) if unique_id and sheet_name not in sheet_name_to_unique_id : sheet_name_to_unique_id [ sheet_name ] = unique_id return sheet_name_to_unique_id