# Path: oslo_db/_i18n.py

# 
# Path: oslo_db/exception.py
# class DBError(CausedByException):
# class DBDuplicateEntry(DBError):
# class DBConstraintError(DBError):
# class DBReferenceError(DBError):
# class DBNonExistentConstraint(DBError):
# class DBNonExistentTable(DBError):
# class DBNonExistentDatabase(DBError):
# class DBDeadlock(DBError):
# class DBInvalidUnicodeParameter(Exception):
# class DBMigrationError(DBError):
# class DBConnectionError(DBError):
# class DBDataError(DBError):
# class DBNotSupportedError(DBError):
# class InvalidSortKey(Exception):
# class ColumnError(Exception):
# class BackendNotAvailable(Exception):
# class RetryRequest(Exception):
# class NoEngineContextEstablished(AttributeError):
# class ContextNotRequestedError(AttributeError):
# class CantStartEngineError(Exception):
#     def __init__(self, inner_exception=None, cause=None):
#     def __init__(self, columns=None, inner_exception=None, value=None):
#     def __init__(self, table, check_name, inner_exception=None):
#     def __init__(self, table, constraint, key, key_table,
#                  inner_exception=None):
#     def __init__(self, table, constraint, inner_exception=None):
#     def __init__(self, table, inner_exception=None):
#     def __init__(self, database, inner_exception=None):
#     def __init__(self, inner_exception=None):
#     def __init__(self):
#     def __init__(self, message):
#     def __init__(self, key=None):
#     def __init__(self, inner_exc):
# 
# Path: oslo_db/sqlalchemy/models.py
# class ModelBase(object):
# class ModelIterator(object):
# class TimestampMixin(object):
# class SoftDeleteMixin(object):
#     def save(self, session):
#     def __setitem__(self, key, value):
#     def __getitem__(self, key):
#     def __contains__(self, key):
#     def get(self, key, default=None):
#     def _extra_keys(self):
#     def __iter__(self):
#     def update(self, values):
#     def _as_dict(self):
#     def iteritems(self):
#     def items(self):
#     def keys(self):
#     def __init__(self, model, columns):
#     def __iter__(self):
#     def __next__(self):
#     def soft_delete(self, session):
# 
# Path: oslo_db/sqlalchemy/ndb.py
# def enable_ndb_support(engine):
# def ndb_status(engine_or_compiler):
# def init_ndb_events(engine):
#     def before_cursor_execute(conn, cursor, statement, parameters, context,
#                               executemany):
# def prefix_inserts(create_table, compiler, **kw):
# def _compile_ndb_string(element, compiler, **kw):


import collections
import contextlib
import itertools
import logging
import re
import debtcollector.removals
import sqlalchemy
from collections import abc
from alembic.migration import MigrationContext
from alembic.operations import Operations
from oslo_utils import timeutils
from sqlalchemy import Boolean
from sqlalchemy import CheckConstraint
from sqlalchemy import Column
from sqlalchemy.engine import Connectable
from sqlalchemy.engine import url as sa_url
from sqlalchemy import exc
from sqlalchemy import func
from sqlalchemy import Index
from sqlalchemy import inspect
from sqlalchemy import Integer
from sqlalchemy import MetaData
from sqlalchemy.sql.expression import cast
from sqlalchemy.sql.expression import literal_column
from sqlalchemy.sql import text
from sqlalchemy import String
from sqlalchemy import Table
from sqlalchemy.types import NullType
from oslo_db._i18n import _
from oslo_db import exception
from oslo_db.sqlalchemy import models
from oslo_db.sqlalchemy import ndb
    return query


def to_list(x, default=None):
    if x is None:
        return default
    if not isinstance(x, abc.Iterable) or isinstance(x, str):
        return [x]
    elif isinstance(x, list):
        return x
    else:
        return list(x)


def _read_deleted_filter(query, db_model, deleted):
    if 'deleted' not in db_model.__table__.columns:
        raise ValueError(_("There is no `deleted` column in `%s` table. "
                           "Project doesn't use soft-deleted feature.")
                         % db_model.__name__)

    default_deleted_value = db_model.__table__.c.deleted.default.arg
    if deleted:
        query = query.filter(db_model.deleted != default_deleted_value)
    else:
        query = query.filter(db_model.deleted == default_deleted_value)
    return query


def _project_filter(query, db_model, project_id):
    if 'project_id' not in db_model.__table__.columns:

# Path: oslo_db/_i18n.py

# 
# Path: oslo_db/exception.py
# class DBError(CausedByException):
# class DBDuplicateEntry(DBError):
# class DBConstraintError(DBError):
# class DBReferenceError(DBError):
# class DBNonExistentConstraint(DBError):
# class DBNonExistentTable(DBError):
# class DBNonExistentDatabase(DBError):
# class DBDeadlock(DBError):
# class DBInvalidUnicodeParameter(Exception):
# class DBMigrationError(DBError):
# class DBConnectionError(DBError):
# class DBDataError(DBError):
# class DBNotSupportedError(DBError):
# class InvalidSortKey(Exception):
# class ColumnError(Exception):
# class BackendNotAvailable(Exception):
# class RetryRequest(Exception):
# class NoEngineContextEstablished(AttributeError):
# class ContextNotRequestedError(AttributeError):
# class CantStartEngineError(Exception):
#     def __init__(self, inner_exception=None, cause=None):
#     def __init__(self, columns=None, inner_exception=None, value=None):
#     def __init__(self, table, check_name, inner_exception=None):
#     def __init__(self, table, constraint, key, key_table,
#                  inner_exception=None):
#     def __init__(self, table, constraint, inner_exception=None):
#     def __init__(self, table, inner_exception=None):
#     def __init__(self, database, inner_exception=None):
#     def __init__(self, inner_exception=None):
#     def __init__(self):
#     def __init__(self, message):
#     def __init__(self, key=None):
#     def __init__(self, inner_exc):
# 
# Path: oslo_db/sqlalchemy/models.py
# class ModelBase(object):
# class ModelIterator(object):
# class TimestampMixin(object):
# class SoftDeleteMixin(object):
#     def save(self, session):
#     def __setitem__(self, key, value):
#     def __getitem__(self, key):
#     def __contains__(self, key):
#     def get(self, key, default=None):
#     def _extra_keys(self):
#     def __iter__(self):
#     def update(self, values):
#     def _as_dict(self):
#     def iteritems(self):
#     def items(self):
#     def keys(self):
#     def __init__(self, model, columns):
#     def __iter__(self):
#     def __next__(self):
#     def soft_delete(self, session):
# 
# Path: oslo_db/sqlalchemy/ndb.py
# def enable_ndb_support(engine):
# def ndb_status(engine_or_compiler):
# def init_ndb_events(engine):
#     def before_cursor_execute(conn, cursor, statement, parameters, context,
#                               executemany):
# def prefix_inserts(create_table, compiler, **kw):
# def _compile_ndb_string(element, compiler, **kw):


# Path: oslo_db/sqlalchemy/utils.py
import collections
import contextlib
import itertools
import logging
import re
import debtcollector.removals
import sqlalchemy
from collections import abc
from alembic.migration import MigrationContext
from alembic.operations import Operations
from oslo_utils import timeutils
from sqlalchemy import Boolean
from sqlalchemy import CheckConstraint
from sqlalchemy import Column
from sqlalchemy.engine import Connectable
from sqlalchemy.engine import url as sa_url
from sqlalchemy import exc
from sqlalchemy import func
from sqlalchemy import Index
from sqlalchemy import inspect
from sqlalchemy import Integer
from sqlalchemy import MetaData
from sqlalchemy.sql.expression import cast
from sqlalchemy.sql.expression import literal_column
from sqlalchemy.sql import text
from sqlalchemy import String
from sqlalchemy import Table
from sqlalchemy.types import NullType
from oslo_db._i18n import _
from oslo_db import exception
from oslo_db.sqlalchemy import models
from oslo_db.sqlalchemy import ndb

    return query


def to_list(x, default=None):
    if x is None:
        return default
    if not isinstance(x, abc.Iterable) or isinstance(x, str):
        return [x]
    elif isinstance(x, list):
        return x
    else:
        return list(x)


def _read_deleted_filter(query, db_model, deleted):
    if 'deleted' not in db_model.__table__.columns:
        raise ValueError(_("There is no `deleted` column in `%s` table. "
                           "Project doesn't use soft-deleted feature.")
                         % db_model.__name__)

    default_deleted_value = db_model.__table__.c.deleted.default.arg
    if deleted:
        query = query.filter(db_model.deleted != default_deleted_value)
    else:
        query = query.filter(db_model.deleted == default_deleted_value)
    return query


def _project_filter(query, db_model, project_id):
    if 'project_id' not in db_model.__table__.columns:

        raise ValueError(_("There is no `project_id` column in `%s` table.")