# Path: flattentool/exceptions.py
# class DataErrorWarning(UserWarning):
#     """
#     A warnings that indicates an error in the data, rather than the schema.
# 
#     """
# 
#     pass
# 
# Path: flattentool/i18n.py
# def _(text):
#     lang = get_language()
#     if lang not in translations:
#         lang = "en"
#     return translations[lang].gettext(text)


import csv
import os
import odf.table
import odf.text
import openpyxl
from warnings import warn
from odf.opendocument import OpenDocumentSpreadsheet
from openpyxl.cell.cell import ILLEGAL_CHARACTERS_RE
from flattentool.exceptions import DataErrorWarning
from flattentool.i18n import _
        for sheet_name, sub_sheet in sorted(self.parser.sub_sheets.items()):
            self.write_sheet(sheet_name, sub_sheet)

        self.close()

    def close(self):
        pass


class XLSXOutput(SpreadsheetOutput):
    def open(self):
        # write only means that the output will be streamed
        self.workbook = openpyxl.Workbook(write_only=True)

    def write_sheet(self, sheet_name, sheet):
        sheet_header = list(sheet)
        worksheet = self.workbook.create_sheet()
        worksheet.title = self.sheet_prefix + sheet_name
        worksheet.append(sheet_header)
        for sheet_line in sheet.lines:
            line = []
            for header in sheet_header:
                value = sheet_line.get(header)
                if isinstance(value, str):
                    new_value = ILLEGAL_CHARACTERS_RE.sub("", value)
                    if new_value != value:
                        warn(
                            _(
                                "Character(s) in '{}' are not allowed in a spreadsheet cell. Those character(s) will be removed"
                            ).format(value),

# Path: flattentool/exceptions.py
# class DataErrorWarning(UserWarning):
#     """
#     A warnings that indicates an error in the data, rather than the schema.
# 
#     """
# 
#     pass
# 
# Path: flattentool/i18n.py
# def _(text):
#     lang = get_language()
#     if lang not in translations:
#         lang = "en"
#     return translations[lang].gettext(text)


# Path: flattentool/output.py
import csv
import os
import odf.table
import odf.text
import openpyxl
from warnings import warn
from odf.opendocument import OpenDocumentSpreadsheet
from openpyxl.cell.cell import ILLEGAL_CHARACTERS_RE
from flattentool.exceptions import DataErrorWarning
from flattentool.i18n import _

        for sheet_name, sub_sheet in sorted(self.parser.sub_sheets.items()):
            self.write_sheet(sheet_name, sub_sheet)

        self.close()

    def close(self):
        pass


class XLSXOutput(SpreadsheetOutput):
    def open(self):
        # write only means that the output will be streamed
        self.workbook = openpyxl.Workbook(write_only=True)

    def write_sheet(self, sheet_name, sheet):
        sheet_header = list(sheet)
        worksheet = self.workbook.create_sheet()
        worksheet.title = self.sheet_prefix + sheet_name
        worksheet.append(sheet_header)
        for sheet_line in sheet.lines:
            line = []
            for header in sheet_header:
                value = sheet_line.get(header)
                if isinstance(value, str):
                    new_value = ILLEGAL_CHARACTERS_RE.sub("", value)
                    if new_value != value:
                        warn(
                            _(
                                "Character(s) in '{}' are not allowed in a spreadsheet cell. Those character(s) will be removed"
                            ).format(value),

                            DataErrorWarning,