# Path: flattentool/output.py
# class SpreadsheetOutput(object):
# class XLSXOutput(SpreadsheetOutput):
# class CSVOutput(SpreadsheetOutput):
# class ODSOutput(SpreadsheetOutput):
#     def __init__(
#         self, parser, main_sheet_name="main", output_name="unflattened", sheet_prefix=""
#     ):
#     def open(self):
#     def write_sheet(self, sheet_name, sheet_header, sheet_lines=None):
#     def write_sheets(self):
#     def close(self):
#     def open(self):
#     def write_sheet(self, sheet_name, sheet):
#     def close(self):
#     def open(self):
#     def write_sheet(self, sheet_name, sheet):
#     def open(self):
#     def _make_cell(self, value):
#     def write_sheet(self, sheet_name, sheet):
#     def close(self):
# FORMATS = {"xlsx": XLSXOutput, "csv": CSVOutput, "ods": ODSOutput}
# FORMATS_SUFFIX = {
#     "xlsx": ".xlsx",
#     "ods": ".ods",
#     "csv": "",  # This is the suffix for the directory
# }
# 
# 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/sheet.py
# class Sheet(object):
#     """
#     An abstract representation of a single sheet of a spreadsheet.
# 
#     """
# 
#     def __init__(self, columns=None, root_id="", name=None):
#         self.id_columns = []
#         self.columns = columns if columns else []
#         self.titles = {}
#         self._lines = []
#         self.root_id = root_id
#         self.name = name
# 
#     @property
#     def lines(self):
#         return self._lines
# 
#     def add_field(self, field, id_field=False):
#         columns = self.id_columns if id_field else self.columns
#         if field not in columns:
#             columns.append(field)
# 
#     def append(self, item):
#         self.add_field(item)
# 
#     def __iter__(self):
#         if self.root_id:
#             yield self.root_id
#         for column in self.id_columns:
#             yield column
#         for column in self.columns:
#             yield column
# 
#     def append_line(self, flattened_dict):
#         self._lines.append(flattened_dict)


import os
import sys
import openpyxl
import pytest
from flattentool import output
from flattentool.ODSReader import ODSReader
from flattentool.sheet import Sheet
# -*- coding: utf-8 -*-
from __future__ import unicode_literals





class MockParser(object):
    def __init__(self, main_sheet, sub_sheets):
        self.main_sheet = Sheet(main_sheet)
        self.sub_sheets = {k: Sheet(v) for k, v in sub_sheets.items()}


def test_spreadsheetouput_base_fails():
    """The base class should fail as it is missing functionality that child
    classes must implement"""


# Path: flattentool/output.py
# class SpreadsheetOutput(object):
# class XLSXOutput(SpreadsheetOutput):
# class CSVOutput(SpreadsheetOutput):
# class ODSOutput(SpreadsheetOutput):
#     def __init__(
#         self, parser, main_sheet_name="main", output_name="unflattened", sheet_prefix=""
#     ):
#     def open(self):
#     def write_sheet(self, sheet_name, sheet_header, sheet_lines=None):
#     def write_sheets(self):
#     def close(self):
#     def open(self):
#     def write_sheet(self, sheet_name, sheet):
#     def close(self):
#     def open(self):
#     def write_sheet(self, sheet_name, sheet):
#     def open(self):
#     def _make_cell(self, value):
#     def write_sheet(self, sheet_name, sheet):
#     def close(self):
# FORMATS = {"xlsx": XLSXOutput, "csv": CSVOutput, "ods": ODSOutput}
# FORMATS_SUFFIX = {
#     "xlsx": ".xlsx",
#     "ods": ".ods",
#     "csv": "",  # This is the suffix for the directory
# }
# 
# 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/sheet.py
# class Sheet(object):
#     """
#     An abstract representation of a single sheet of a spreadsheet.
# 
#     """
# 
#     def __init__(self, columns=None, root_id="", name=None):
#         self.id_columns = []
#         self.columns = columns if columns else []
#         self.titles = {}
#         self._lines = []
#         self.root_id = root_id
#         self.name = name
# 
#     @property
#     def lines(self):
#         return self._lines
# 
#     def add_field(self, field, id_field=False):
#         columns = self.id_columns if id_field else self.columns
#         if field not in columns:
#             columns.append(field)
# 
#     def append(self, item):
#         self.add_field(item)
# 
#     def __iter__(self):
#         if self.root_id:
#             yield self.root_id
#         for column in self.id_columns:
#             yield column
#         for column in self.columns:
#             yield column
# 
#     def append_line(self, flattened_dict):
#         self._lines.append(flattened_dict)


# Path: flattentool/tests/test_output.py
import os
import sys
import openpyxl
import pytest
from flattentool import output
from flattentool.ODSReader import ODSReader
from flattentool.sheet import Sheet

# -*- coding: utf-8 -*-
from __future__ import unicode_literals





class MockParser(object):
    def __init__(self, main_sheet, sub_sheets):
        self.main_sheet = Sheet(main_sheet)
        self.sub_sheets = {k: Sheet(v) for k, v in sub_sheets.items()}


def test_spreadsheetouput_base_fails():
    """The base class should fail as it is missing functionality that child
    classes must implement"""


    spreadsheet_output = output.SpreadsheetOutput(parser=MockParser([], {}))