# 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/lib.py
# def isint(string):
#     try:
#         int(string)
#         return True
#     except ValueError:
#         return False
# 
# def parse_sheet_configuration(configuration_list):
#     configuration = {}
#     for item in configuration_list:
#         parts = item.split()
#         if len(parts) == 2 and parts[0].lower() == "skiprows" and isint(parts[1]):
#             configuration["skipRows"] = max(int(parts[1]), 0)
#         if len(parts) == 2 and parts[0].lower() == "headerrows" and isint(parts[1]):
#             configuration["headerRows"] = max(int(parts[1]), 1)
#         if len(parts) == 1 and parts[0].lower() == "ignore":
#             configuration["ignore"] = True
#         if len(parts) == 1 and parts[0].lower() in ("hashcomments", "hashcomment"):
#             configuration["hashcomments"] = True
#         if len(parts) == 2 and parts[0].lower() == "xmlroottag":
#             configuration["XMLRootTag"] = parts[1]
#         if len(parts) == 2 and parts[0].lower() == "rootlistpath":
#             configuration["RootListPath"] = parts[1]
#         if len(parts) == 2 and parts[0].lower() == "idname":
#             configuration["IDName"] = parts[1]
#     return configuration
# 
# Path: flattentool/ODSReader.py
# class ODSReader:
# 
#     # loads the file
#     def __init__(self, file, clonespannedcolumns=None):
#         self.clonespannedcolumns = clonespannedcolumns
#         self.doc = odf.opendocument.load(file)
#         self.SHEETS = OrderedDict()
#         for sheet in self.doc.spreadsheet.getElementsByType(Table):
#             self.readSheet(sheet)
# 
#     # reads a sheet in the sheet dictionary, storing each sheet as an
#     # array (rows) of arrays (columns)
#     def readSheet(self, sheet):
#         name = sheet.getAttribute("name")
#         rows = sheet.getElementsByType(TableRow)
#         arrRows = []
# 
#         # for each row
#         for row in rows:
#             row_comment = ""  # noqa
#             arrCells = GrowingList()
#             cells = row.getElementsByType(TableCell)
# 
#             # for each cell
#             count = 0
#             for cell in cells:
#                 # repeated value?
#                 repeat = cell.getAttribute("numbercolumnsrepeated")
#                 if not repeat:
#                     repeat = 1
#                     spanned = int(cell.getAttribute("numbercolumnsspanned") or 0)
#                     # clone spanned cells
#                     if self.clonespannedcolumns is not None and spanned > 1:
#                         repeat = spanned
# 
#                 for rr in range(int(repeat)):  # repeated?
#                     if str(cell):
#                         value_type = cell.attributes.get(
#                             (
#                                 "urn:oasis:names:tc:opendocument:xmlns:office:1.0",
#                                 "value-type",
#                             )
#                         )
#                         if value_type == "float":
#                             value = cell.attributes.get(
#                                 (
#                                     "urn:oasis:names:tc:opendocument:xmlns:office:1.0",
#                                     "value",
#                                 )
#                             )
#                             if "." in str(value):
#                                 arrCells[count] = float(value)
#                             else:
#                                 arrCells[count] = int(value)
#                         elif value_type == "date":
#                             date_value = cell.attributes.get(
#                                 (
#                                     "urn:oasis:names:tc:opendocument:xmlns:office:1.0",
#                                     "date-value",
#                                 )
#                             )
#                             # fromisoformat assumes microseconds appear as 3 or
#                             # 6 digits, whereas ods drops trailing 0s, so can
#                             # have 1-6 digits, so pad some extra 0s
#                             if "." in date_value:
#                                 date_value = date_value.ljust(26, "0")
#                             arrCells[count] = datetime.fromisoformat(date_value)
#                         else:
#                             arrCells[count] = str(cell)
#                     count += 1
# 
#             arrRows.append(arrCells)
# 
#         self.SHEETS[name] = arrRows
# 
#     # returns a sheet as an array (rows) of arrays (columns)
#     def getSheet(self, name):
#         return self.SHEETS[name]


import datetime
import os
import openpyxl
import pytz
from collections import OrderedDict, UserDict
from csv import DictReader
from csv import reader as csvreader
from decimal import Decimal, InvalidOperation
from warnings import warn
from openpyxl.utils.cell import _get_column_letter
from flattentool.exceptions import DataErrorWarning
from flattentool.i18n import _
from flattentool.lib import isint, parse_sheet_configuration
from flattentool.ODSReader import ODSReader
    from zipfile import BadZipFile
    from zipfile import BadZipfile as BadZipFile
        self.root_list_path = root_list_path
        self.root_is_list = root_is_list
        self.sub_sheet_names = []
        self.timezone = pytz.timezone(timezone_name)
        self.root_id = root_id
        self.convert_titles = convert_titles
        self.id_name = id_name
        self.xml = xml
        self.parser = None
        self.vertical_orientation = vertical_orientation
        self.include_sheets = include_sheets
        self.exclude_sheets = exclude_sheets
        self.base_configuration = base_configuration or {}
        self.sheet_configuration = {}
        self.use_configuration = use_configuration

    def get_sub_sheets_lines(self):
        for sub_sheet_name in self.sub_sheet_names:
            if self.convert_titles:
                yield sub_sheet_name, self.convert_dict_titles(
                    self.get_sheet_lines(sub_sheet_name),
                    self.parser.sub_sheets[sub_sheet_name].title_lookup
                    if sub_sheet_name in self.parser.sub_sheets
                    else None,
                )
            else:
                yield sub_sheet_name, self.get_sheet_lines(sub_sheet_name)

    def configure_sheets(self):
        for sub_sheet_name in self.sub_sheet_names:

# 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/lib.py
# def isint(string):
#     try:
#         int(string)
#         return True
#     except ValueError:
#         return False
# 
# def parse_sheet_configuration(configuration_list):
#     configuration = {}
#     for item in configuration_list:
#         parts = item.split()
#         if len(parts) == 2 and parts[0].lower() == "skiprows" and isint(parts[1]):
#             configuration["skipRows"] = max(int(parts[1]), 0)
#         if len(parts) == 2 and parts[0].lower() == "headerrows" and isint(parts[1]):
#             configuration["headerRows"] = max(int(parts[1]), 1)
#         if len(parts) == 1 and parts[0].lower() == "ignore":
#             configuration["ignore"] = True
#         if len(parts) == 1 and parts[0].lower() in ("hashcomments", "hashcomment"):
#             configuration["hashcomments"] = True
#         if len(parts) == 2 and parts[0].lower() == "xmlroottag":
#             configuration["XMLRootTag"] = parts[1]
#         if len(parts) == 2 and parts[0].lower() == "rootlistpath":
#             configuration["RootListPath"] = parts[1]
#         if len(parts) == 2 and parts[0].lower() == "idname":
#             configuration["IDName"] = parts[1]
#     return configuration
# 
# Path: flattentool/ODSReader.py
# class ODSReader:
# 
#     # loads the file
#     def __init__(self, file, clonespannedcolumns=None):
#         self.clonespannedcolumns = clonespannedcolumns
#         self.doc = odf.opendocument.load(file)
#         self.SHEETS = OrderedDict()
#         for sheet in self.doc.spreadsheet.getElementsByType(Table):
#             self.readSheet(sheet)
# 
#     # reads a sheet in the sheet dictionary, storing each sheet as an
#     # array (rows) of arrays (columns)
#     def readSheet(self, sheet):
#         name = sheet.getAttribute("name")
#         rows = sheet.getElementsByType(TableRow)
#         arrRows = []
# 
#         # for each row
#         for row in rows:
#             row_comment = ""  # noqa
#             arrCells = GrowingList()
#             cells = row.getElementsByType(TableCell)
# 
#             # for each cell
#             count = 0
#             for cell in cells:
#                 # repeated value?
#                 repeat = cell.getAttribute("numbercolumnsrepeated")
#                 if not repeat:
#                     repeat = 1
#                     spanned = int(cell.getAttribute("numbercolumnsspanned") or 0)
#                     # clone spanned cells
#                     if self.clonespannedcolumns is not None and spanned > 1:
#                         repeat = spanned
# 
#                 for rr in range(int(repeat)):  # repeated?
#                     if str(cell):
#                         value_type = cell.attributes.get(
#                             (
#                                 "urn:oasis:names:tc:opendocument:xmlns:office:1.0",
#                                 "value-type",
#                             )
#                         )
#                         if value_type == "float":
#                             value = cell.attributes.get(
#                                 (
#                                     "urn:oasis:names:tc:opendocument:xmlns:office:1.0",
#                                     "value",
#                                 )
#                             )
#                             if "." in str(value):
#                                 arrCells[count] = float(value)
#                             else:
#                                 arrCells[count] = int(value)
#                         elif value_type == "date":
#                             date_value = cell.attributes.get(
#                                 (
#                                     "urn:oasis:names:tc:opendocument:xmlns:office:1.0",
#                                     "date-value",
#                                 )
#                             )
#                             # fromisoformat assumes microseconds appear as 3 or
#                             # 6 digits, whereas ods drops trailing 0s, so can
#                             # have 1-6 digits, so pad some extra 0s
#                             if "." in date_value:
#                                 date_value = date_value.ljust(26, "0")
#                             arrCells[count] = datetime.fromisoformat(date_value)
#                         else:
#                             arrCells[count] = str(cell)
#                     count += 1
# 
#             arrRows.append(arrCells)
# 
#         self.SHEETS[name] = arrRows
# 
#     # returns a sheet as an array (rows) of arrays (columns)
#     def getSheet(self, name):
#         return self.SHEETS[name]


# Path: flattentool/input.py
import datetime
import os
import openpyxl
import pytz
from collections import OrderedDict, UserDict
from csv import DictReader
from csv import reader as csvreader
from decimal import Decimal, InvalidOperation
from warnings import warn
from openpyxl.utils.cell import _get_column_letter
from flattentool.exceptions import DataErrorWarning
from flattentool.i18n import _
from flattentool.lib import isint, parse_sheet_configuration
from flattentool.ODSReader import ODSReader
    from zipfile import BadZipFile
    from zipfile import BadZipfile as BadZipFile

        self.root_list_path = root_list_path
        self.root_is_list = root_is_list
        self.sub_sheet_names = []
        self.timezone = pytz.timezone(timezone_name)
        self.root_id = root_id
        self.convert_titles = convert_titles
        self.id_name = id_name
        self.xml = xml
        self.parser = None
        self.vertical_orientation = vertical_orientation
        self.include_sheets = include_sheets
        self.exclude_sheets = exclude_sheets
        self.base_configuration = base_configuration or {}
        self.sheet_configuration = {}
        self.use_configuration = use_configuration

    def get_sub_sheets_lines(self):
        for sub_sheet_name in self.sub_sheet_names:
            if self.convert_titles:
                yield sub_sheet_name, self.convert_dict_titles(
                    self.get_sheet_lines(sub_sheet_name),
                    self.parser.sub_sheets[sub_sheet_name].title_lookup
                    if sub_sheet_name in self.parser.sub_sheets
                    else None,
                )
            else:
                yield sub_sheet_name, self.get_sheet_lines(sub_sheet_name)

    def configure_sheets(self):
        for sub_sheet_name in self.sub_sheet_names:

            self.sheet_configuration[sub_sheet_name] = parse_sheet_configuration(