# Path: cellpy/utils/batch_tools/batch_core.py
# class BaseExporter(Doer, metaclass=abc.ABCMeta):
#     """An exporter exports your data to a given format."""
# 
#     def __init__(self, *args):
#         super().__init__(*args)
#         self._use_dir = None
#         self.current_engine = None
# 
#     def run_engine(self, engine):
#         logging.debug(f"start engine::{engine.__name__}")
#         self.current_engine = engine
#         self.farms, self.barn = engine(experiments=self.experiments, farms=self.farms)
#         logging.debug("::engine ended")
# 
#     def run_dumper(self, dumper):
#         logging.debug(f"start dumper::{dumper.__name__}")
#         dumper(
#             experiments=self.experiments,
#             farms=self.farms,
#             barn=self.barn,
#             engine=self.current_engine,
#         )
#         logging.debug("::engine ended")
# 
# Path: cellpy/utils/batch_tools/dumpers.py
# def csv_dumper(**kwargs):
#     """dump data to csv"""
#     logging.debug("dumping to csv")
#     barn = kwargs["barn"]
#     farms = kwargs["farms"]
#     experiments = kwargs["experiments"]
#     for experiment, farm in zip(experiments, farms):
#         name = experiment.journal.name
#         project = experiment.journal.project
#         project_dir, batch_dir, raw_dir = experiment.journal.paginate()
#         if batch_dir is None:
#             logging.debug("have to generate folder-name on the fly")
#             out_data_dir, project_dir, batch_dir, raw_dir = generate_folder_names(
#                 name, project
#             )
# 
#         if barn == "batch_dir":
#             out_dir = batch_dir
#         elif barn == "project_dir":
#             out_dir = project_dir
#         elif barn == "raw_dir":
#             out_dir = raw_dir
#         else:
#             out_dir = barn
# 
#         for animal in farm:
#             file_name = os.path.join(out_dir, "summary_%s_%s.csv" % (animal.name, name))
#             logging.info(f"> {file_name}")
#             animal.to_csv(file_name, sep=prms.Reader.sep)
# 
# def screen_dumper(**kwargs):
#     """Dump data to screen."""
#     farms = kwargs["farms"]
#     engine = kwargs["engine"]
#     logging.info("dumping to screen")
# 
#     print(f"\n[Screen dumper] ({engine})")
#     try:
#         if len(farms) == 1:
#             print(f"You have one farm with little pandas.")
# 
#         else:
#             print(f"You have {len(farms)} farms with little pandas.")
#     except TypeError:
#         print(" - your farm has burned to the ground.")
#     else:
#         for number, farm in enumerate(farms):
#             print(f"[#{number + 1}]You have {len(farm)} little pandas in this farm.")
#             for animal in farm:
#                 print(80 * "=")
#                 try:
#                     print(animal.name)
#                 except AttributeError:
#                     print("no-name")
#                 print(80 * "-")
#                 print(animal.head(5))
#                 print()
# 
# Path: cellpy/utils/batch_tools/engines.py
# def cycles_engine(**kwargs):
#     """engine to extract cycles"""
#     logging.debug("cycles_engine::Not finished yet (sorry).")
#     # raise NotImplementedError
# 
#     experiments = kwargs["experiments"]
# 
#     farms = []
#     barn = "raw_dir"  # Its a murder in the red barn - murder in the red barn
# 
#     for experiment in experiments:
#         farms.append([])
#         if experiment.all_in_memory:
#             logging.debug("all in memory")
#             for key in experiment.cell_data_frames:
#                 logging.debug(f"extracting cycles from {key}")
#                 # extract cycles here and send it to the farm
#         else:
#             logging.debug("dont have it in memory - need to lookup in the files")
#             for key in experiment.cell_data_frames:
#                 logging.debug(f"looking up cellpyfile for {key}")
#                 # extract cycles here and send it to the farm
# 
#     return farms, barn
# 
# def summary_engine(**kwargs):
#     """engine to extract summary data"""
#     logging.debug("summary_engine")
#     # farms = kwargs["farms"]
# 
#     farms = []
#     experiments = kwargs.pop("experiments")
#     reset = kwargs.pop("reset", False)
# 
#     for experiment in experiments:
#         if experiment.selected_summaries is None:
#             selected_summaries = SELECTED_SUMMARIES
#         else:
#             selected_summaries = experiment.selected_summaries
# 
#         if reset or experiment.summary_frames is None:
#             logging.debug("No summary frames found")
#             logging.debug("Re-loading")
#             experiment.summary_frames = _load_summaries(experiment)
# 
#         farm = helper.join_summaries(experiment.summary_frames, selected_summaries)
#         farms.append(farm)
#     barn = "batch_dir"
# 
#     return farms, barn


import logging
from cellpy.utils.batch_tools.batch_core import BaseExporter
from cellpy.utils.batch_tools.dumpers import csv_dumper, screen_dumper
from cellpy.utils.batch_tools.engines import cycles_engine, summary_engine
        logging.debug("running engine")
        self.current_engine = engine

        self.farms, self.barn = engine(experiments=self.experiments, farms=self.farms)

    def run_dumper(self, dumper):
        """run dumber (once pr. engine)

        Args:
            dumper: dumper to run (function or method).

        The dumper takes the attributes experiments, farms, and barn as input.
        """

        logging.debug("running dumper")
        dumper(
            experiments=self.experiments,
            farms=self.farms,
            barn=self.barn,
            engine=self.current_engine,
        )


class OriginLabExporter(BaseExporter):
    """Exporter that saves the files in a format convenient for OriginLab."""

    def __init__(self):
        super().__init__()



# Path: cellpy/utils/batch_tools/batch_core.py
# class BaseExporter(Doer, metaclass=abc.ABCMeta):
#     """An exporter exports your data to a given format."""
# 
#     def __init__(self, *args):
#         super().__init__(*args)
#         self._use_dir = None
#         self.current_engine = None
# 
#     def run_engine(self, engine):
#         logging.debug(f"start engine::{engine.__name__}")
#         self.current_engine = engine
#         self.farms, self.barn = engine(experiments=self.experiments, farms=self.farms)
#         logging.debug("::engine ended")
# 
#     def run_dumper(self, dumper):
#         logging.debug(f"start dumper::{dumper.__name__}")
#         dumper(
#             experiments=self.experiments,
#             farms=self.farms,
#             barn=self.barn,
#             engine=self.current_engine,
#         )
#         logging.debug("::engine ended")
# 
# Path: cellpy/utils/batch_tools/dumpers.py
# def csv_dumper(**kwargs):
#     """dump data to csv"""
#     logging.debug("dumping to csv")
#     barn = kwargs["barn"]
#     farms = kwargs["farms"]
#     experiments = kwargs["experiments"]
#     for experiment, farm in zip(experiments, farms):
#         name = experiment.journal.name
#         project = experiment.journal.project
#         project_dir, batch_dir, raw_dir = experiment.journal.paginate()
#         if batch_dir is None:
#             logging.debug("have to generate folder-name on the fly")
#             out_data_dir, project_dir, batch_dir, raw_dir = generate_folder_names(
#                 name, project
#             )
# 
#         if barn == "batch_dir":
#             out_dir = batch_dir
#         elif barn == "project_dir":
#             out_dir = project_dir
#         elif barn == "raw_dir":
#             out_dir = raw_dir
#         else:
#             out_dir = barn
# 
#         for animal in farm:
#             file_name = os.path.join(out_dir, "summary_%s_%s.csv" % (animal.name, name))
#             logging.info(f"> {file_name}")
#             animal.to_csv(file_name, sep=prms.Reader.sep)
# 
# def screen_dumper(**kwargs):
#     """Dump data to screen."""
#     farms = kwargs["farms"]
#     engine = kwargs["engine"]
#     logging.info("dumping to screen")
# 
#     print(f"\n[Screen dumper] ({engine})")
#     try:
#         if len(farms) == 1:
#             print(f"You have one farm with little pandas.")
# 
#         else:
#             print(f"You have {len(farms)} farms with little pandas.")
#     except TypeError:
#         print(" - your farm has burned to the ground.")
#     else:
#         for number, farm in enumerate(farms):
#             print(f"[#{number + 1}]You have {len(farm)} little pandas in this farm.")
#             for animal in farm:
#                 print(80 * "=")
#                 try:
#                     print(animal.name)
#                 except AttributeError:
#                     print("no-name")
#                 print(80 * "-")
#                 print(animal.head(5))
#                 print()
# 
# Path: cellpy/utils/batch_tools/engines.py
# def cycles_engine(**kwargs):
#     """engine to extract cycles"""
#     logging.debug("cycles_engine::Not finished yet (sorry).")
#     # raise NotImplementedError
# 
#     experiments = kwargs["experiments"]
# 
#     farms = []
#     barn = "raw_dir"  # Its a murder in the red barn - murder in the red barn
# 
#     for experiment in experiments:
#         farms.append([])
#         if experiment.all_in_memory:
#             logging.debug("all in memory")
#             for key in experiment.cell_data_frames:
#                 logging.debug(f"extracting cycles from {key}")
#                 # extract cycles here and send it to the farm
#         else:
#             logging.debug("dont have it in memory - need to lookup in the files")
#             for key in experiment.cell_data_frames:
#                 logging.debug(f"looking up cellpyfile for {key}")
#                 # extract cycles here and send it to the farm
# 
#     return farms, barn
# 
# def summary_engine(**kwargs):
#     """engine to extract summary data"""
#     logging.debug("summary_engine")
#     # farms = kwargs["farms"]
# 
#     farms = []
#     experiments = kwargs.pop("experiments")
#     reset = kwargs.pop("reset", False)
# 
#     for experiment in experiments:
#         if experiment.selected_summaries is None:
#             selected_summaries = SELECTED_SUMMARIES
#         else:
#             selected_summaries = experiment.selected_summaries
# 
#         if reset or experiment.summary_frames is None:
#             logging.debug("No summary frames found")
#             logging.debug("Re-loading")
#             experiment.summary_frames = _load_summaries(experiment)
# 
#         farm = helper.join_summaries(experiment.summary_frames, selected_summaries)
#         farms.append(farm)
#     barn = "batch_dir"
# 
#     return farms, barn


# Path: cellpy/utils/batch_tools/batch_exporters.py
import logging
from cellpy.utils.batch_tools.batch_core import BaseExporter
from cellpy.utils.batch_tools.dumpers import csv_dumper, screen_dumper
from cellpy.utils.batch_tools.engines import cycles_engine, summary_engine

        logging.debug("running engine")
        self.current_engine = engine

        self.farms, self.barn = engine(experiments=self.experiments, farms=self.farms)

    def run_dumper(self, dumper):
        """run dumber (once pr. engine)

        Args:
            dumper: dumper to run (function or method).

        The dumper takes the attributes experiments, farms, and barn as input.
        """

        logging.debug("running dumper")
        dumper(
            experiments=self.experiments,
            farms=self.farms,
            barn=self.barn,
            engine=self.current_engine,
        )


class OriginLabExporter(BaseExporter):
    """Exporter that saves the files in a format convenient for OriginLab."""

    def __init__(self):
        super().__init__()



class ExcelExporter(BaseExporter):