# Path: seedbox/process/flow.py
# LOG = logging.getLogger(__name__)
# class Taskflow(xworkflows.Workflow):
# class BaseFlow(xworkflows.WorkflowEnabled):
#     def __init__(self, dbapi, torrent):
#     def tasks(self):
#     def phase(self):
#     def is_done(self):
#     def next_tasks(self):
#     def update_state(self, *args, **kwargs):
#     def validate(self):
#     def prepare(self):
#     def activate(self):
#     def complete(self):
# def get_tasks(phase):


import logging
from seedbox.process import flow
"""Workflow implementation that handles automatic execution.

Continues to process each step until the workflow reaches completion.

::

    wf = Workflow(torrent)
    tasks = wf.next_tasks()
    # execute tasks in separate threads
    <<logic>>
    # now move the workflow to the next step
    wf.run()

"""


LOG = logging.getLogger(__name__)


class Workflow(flow.BaseFlow):
    """Implementation that handles the orchestration of the process"""

    def run(self):
        """Orchestrate each step of the process based on current state"""

        if not self.is_done():
            next_step = getattr(self, self.phase)
            LOG.debug('next_step: %s', next_step)
            try:
                next_step()

# Path: seedbox/process/flow.py
# LOG = logging.getLogger(__name__)
# class Taskflow(xworkflows.Workflow):
# class BaseFlow(xworkflows.WorkflowEnabled):
#     def __init__(self, dbapi, torrent):
#     def tasks(self):
#     def phase(self):
#     def is_done(self):
#     def next_tasks(self):
#     def update_state(self, *args, **kwargs):
#     def validate(self):
#     def prepare(self):
#     def activate(self):
#     def complete(self):
# def get_tasks(phase):


# Path: seedbox/process/workflow.py
import logging
from seedbox.process import flow

"""Workflow implementation that handles automatic execution.

Continues to process each step until the workflow reaches completion.

::

    wf = Workflow(torrent)
    tasks = wf.next_tasks()
    # execute tasks in separate threads
    <<logic>>
    # now move the workflow to the next step
    wf.run()

"""


LOG = logging.getLogger(__name__)


class Workflow(flow.BaseFlow):
    """Implementation that handles the orchestration of the process"""

    def run(self):
        """Orchestrate each step of the process based on current state"""

        if not self.is_done():
            next_step = getattr(self, self.phase)
            LOG.debug('next_step: %s', next_step)
            try:
                next_step()

            except (flow.WorkflowError, flow.AbortTransition,