# Path: sqlalchemy_continuum/utils.py
# def adapt_columns(expr):
#     return VersioningClauseAdapter().traverse(expr)
# 
# def option(obj_or_class, option_name):
#     """
#     Return the option value of given option for given versioned object or
#     class.
# 
#     :param obj_or_class: SQLAlchemy declarative model object or class
#     :param option_name: The name of an option to return
#     """
#     if isinstance(obj_or_class, AliasedClass):
#         obj_or_class = sa.inspect(obj_or_class).mapper.class_
#     cls = obj_or_class if isclass(obj_or_class) else obj_or_class.__class__
#     if not hasattr(cls, '__versioned__'):
#         cls = parent_class(cls)
#     return get_versioning_manager(cls).option(
#         cls, option_name
#     )


from copy import copy
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.orm import column_property
from sqlalchemy_utils.functions import get_declarative_base
from .utils import adapt_columns, option
from .version import VersionClassBase
import six
import sqlalchemy as sa



def find_closest_versioned_parent(manager, model):
    """
    Finds the closest versioned parent for current parent model.
    """
    for class_ in model.__bases__:
        if class_ in manager.version_class_map:
            return manager.version_class_map[class_]

def versioned_parents(manager, model):
    """
    Finds all versioned ancestors for current parent model.
    """
    for class_ in model.__mro__:
        if class_ in manager.version_class_map:
            yield manager.version_class_map[class_]


def get_base_class(manager, model):
    """
    Returns all base classes for history model.
    """
    return (

# Path: sqlalchemy_continuum/utils.py
# def adapt_columns(expr):
#     return VersioningClauseAdapter().traverse(expr)
# 
# def option(obj_or_class, option_name):
#     """
#     Return the option value of given option for given versioned object or
#     class.
# 
#     :param obj_or_class: SQLAlchemy declarative model object or class
#     :param option_name: The name of an option to return
#     """
#     if isinstance(obj_or_class, AliasedClass):
#         obj_or_class = sa.inspect(obj_or_class).mapper.class_
#     cls = obj_or_class if isclass(obj_or_class) else obj_or_class.__class__
#     if not hasattr(cls, '__versioned__'):
#         cls = parent_class(cls)
#     return get_versioning_manager(cls).option(
#         cls, option_name
#     )


# Path: sqlalchemy_continuum/model_builder.py
from copy import copy
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.orm import column_property
from sqlalchemy_utils.functions import get_declarative_base
from .utils import adapt_columns, option
from .version import VersionClassBase
import six
import sqlalchemy as sa




def find_closest_versioned_parent(manager, model):
    """
    Finds the closest versioned parent for current parent model.
    """
    for class_ in model.__bases__:
        if class_ in manager.version_class_map:
            return manager.version_class_map[class_]

def versioned_parents(manager, model):
    """
    Finds all versioned ancestors for current parent model.
    """
    for class_ in model.__mro__:
        if class_ in manager.version_class_map:
            yield manager.version_class_map[class_]


def get_base_class(manager, model):
    """
    Returns all base classes for history model.
    """
    return (

        option(model, 'base_classes')