move all exception classes to migrate.exceptions
This commit is contained in:
parent
28f06524b5
commit
653e723ce1
20
docs/api.rst
20
docs/api.rst
@ -1,3 +1,10 @@
|
||||
Module :mod:`exceptions <migrate.exceptions>` -- Exception definitions
|
||||
---------------------------------------------------------------------------------------
|
||||
|
||||
.. automodule:: migrate.exceptions
|
||||
:members:
|
||||
:synopsis: Migrate exception classes
|
||||
|
||||
Module :mod:`migrate.changeset` -- Schema migration API
|
||||
=============================================================
|
||||
|
||||
@ -84,13 +91,6 @@ Module :mod:`visitor <migrate.changeset.databases.visitor>`
|
||||
.. automodule:: migrate.changeset.databases.visitor
|
||||
:members:
|
||||
|
||||
Module :mod:`exceptions <migrate.changeset.exceptions>` -- Exception definitions
|
||||
---------------------------------------------------------------------------------------
|
||||
|
||||
.. automodule:: migrate.changeset.exceptions
|
||||
:members:
|
||||
:synopsis: Changeset exception classes
|
||||
|
||||
Module :mod:`schema <migrate.changeset.schema>` -- Additional API to SQLAlchemy for migrations
|
||||
-------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -115,12 +115,6 @@ Module :mod:`api <migrate.versioning.api>` -- Python API commands
|
||||
:members:
|
||||
:synopsis: External API for :mod:`migrate.versioning`
|
||||
|
||||
Module :mod:`exceptions <migrate.versioning.exceptions>` -- Exception definitions
|
||||
--------------------------------------------------------------------------------------
|
||||
|
||||
.. automodule:: migrate.versioning.exceptions
|
||||
:members:
|
||||
:synopsis: Exception classes for :mod:`migrate.versioning`
|
||||
|
||||
Module :mod:`genmodel <migrate.versioning.genmodel>` -- ORM Model generator
|
||||
-------------------------------------------------------------------------------------
|
||||
|
@ -7,6 +7,8 @@ Fixed bugs
|
||||
- updated tests for Python 2.7
|
||||
- added if main condition for manage.py script
|
||||
- fixed case sensitivity in setup.py dependencies
|
||||
- moved :mod:`migrate.changeset.exceptions` and :mod:`migrate.versioning.exceptions`
|
||||
to :mod:`migrate.exceptions`
|
||||
|
||||
0.6 (11.07.2010)
|
||||
---------------------------
|
||||
|
@ -4,6 +4,8 @@
|
||||
At the moment, this isn't so much based off of ANSI as much as
|
||||
things that just happen to work with multiple databases.
|
||||
"""
|
||||
import StringIO
|
||||
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.schema import SchemaVisitor
|
||||
from sqlalchemy.engine.default import DefaultDialect
|
||||
@ -14,8 +16,8 @@ from sqlalchemy.schema import (ForeignKeyConstraint,
|
||||
UniqueConstraint,
|
||||
Index)
|
||||
|
||||
from migrate.changeset import exceptions, constraint, SQLA_06
|
||||
import StringIO
|
||||
from migrate import exceptions
|
||||
from migrate.changeset import constraint, SQLA_06
|
||||
|
||||
if not SQLA_06:
|
||||
from sqlalchemy.sql.compiler import SchemaGenerator, SchemaDropper
|
||||
|
@ -3,7 +3,7 @@
|
||||
"""
|
||||
from sqlalchemy import schema
|
||||
|
||||
from migrate.changeset.exceptions import *
|
||||
from migrate.exceptions import *
|
||||
from migrate.changeset import SQLA_06
|
||||
|
||||
class ConstraintChangeset(object):
|
||||
|
@ -1,10 +1,12 @@
|
||||
"""
|
||||
Firebird database specific implementations of changeset classes.
|
||||
"""
|
||||
|
||||
from migrate.changeset import ansisql, exceptions, SQLA_06
|
||||
from sqlalchemy.databases import firebird as sa_base
|
||||
|
||||
from migrate import exceptions
|
||||
from migrate.changeset import ansisql, SQLA_06
|
||||
|
||||
|
||||
if SQLA_06:
|
||||
FBSchemaGenerator = sa_base.FBDDLCompiler
|
||||
else:
|
||||
|
@ -2,10 +2,13 @@
|
||||
MySQL database specific implementations of changeset classes.
|
||||
"""
|
||||
|
||||
from migrate.changeset import ansisql, exceptions, SQLA_06
|
||||
from sqlalchemy.databases import mysql as sa_base
|
||||
from sqlalchemy import types as sqltypes
|
||||
|
||||
from migrate import exceptions
|
||||
from migrate.changeset import ansisql, SQLA_06
|
||||
|
||||
|
||||
if not SQLA_06:
|
||||
MySQLSchemaGenerator = sa_base.MySQLSchemaGenerator
|
||||
else:
|
||||
|
@ -2,12 +2,11 @@
|
||||
Oracle database specific implementations of changeset classes.
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
|
||||
from migrate.changeset import ansisql, exceptions
|
||||
|
||||
from sqlalchemy.databases import oracle as sa_base
|
||||
|
||||
from migrate.changeset import ansisql, exceptions, SQLA_06
|
||||
from migrate import exceptions
|
||||
from migrate.changeset import ansisql, SQLA_06
|
||||
|
||||
|
||||
if not SQLA_06:
|
||||
OracleSchemaGenerator = sa_base.OracleSchemaGenerator
|
||||
|
@ -8,7 +8,9 @@ from copy import copy
|
||||
|
||||
from sqlalchemy.databases import sqlite as sa_base
|
||||
|
||||
from migrate.changeset import ansisql, exceptions, SQLA_06
|
||||
from migrate import exceptions
|
||||
from migrate.changeset import ansisql, SQLA_06
|
||||
|
||||
|
||||
if not SQLA_06:
|
||||
SQLiteSchemaGenerator = sa_base.SQLiteSchemaGenerator
|
||||
|
@ -1,26 +0,0 @@
|
||||
"""
|
||||
This module provides exception classes.
|
||||
"""
|
||||
|
||||
|
||||
class Error(Exception):
|
||||
"""
|
||||
Changeset error.
|
||||
"""
|
||||
|
||||
|
||||
class NotSupportedError(Error):
|
||||
"""
|
||||
Not supported error.
|
||||
"""
|
||||
|
||||
|
||||
class InvalidConstraintError(Error):
|
||||
"""
|
||||
Invalid constraint error.
|
||||
"""
|
||||
|
||||
class MigrateDeprecationWarning(DeprecationWarning):
|
||||
"""
|
||||
Warning for deprecated features in Migrate
|
||||
"""
|
@ -6,8 +6,8 @@ from UserDict import DictMixin
|
||||
|
||||
import sqlalchemy
|
||||
|
||||
from migrate.exceptions import *
|
||||
from migrate.changeset import SQLA_06
|
||||
from migrate.changeset.exceptions import *
|
||||
from migrate.changeset.databases.visitor import (get_engine_visitor,
|
||||
run_single_visitor)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""
|
||||
Provide exception classes for :mod:`migrate.versioning`
|
||||
Provide exception classes for :mod:`migrate`
|
||||
"""
|
||||
|
||||
|
||||
@ -73,3 +73,15 @@ class InvalidScriptError(ScriptError):
|
||||
|
||||
class InvalidVersionError(Error):
|
||||
"""Invalid version error."""
|
||||
|
||||
# migrate.changeset
|
||||
|
||||
class NotSupportedError(Error):
|
||||
"""Not supported error"""
|
||||
|
||||
|
||||
class InvalidConstraintError(Error):
|
||||
"""Invalid constraint error"""
|
||||
|
||||
class MigrateDeprecationWarning(DeprecationWarning):
|
||||
"""Warning for deprecated features in Migrate"""
|
@ -3,7 +3,7 @@
|
||||
import sqlalchemy
|
||||
from sqlalchemy import *
|
||||
|
||||
from migrate import changeset
|
||||
from migrate import changeset, exceptions
|
||||
from migrate.changeset import *
|
||||
from migrate.changeset.schema import ColumnDelta
|
||||
from migrate.tests import fixture
|
||||
@ -165,7 +165,7 @@ class TestAddDropColumn(fixture.DB):
|
||||
# create column with fk
|
||||
col = Column('data', Integer, ForeignKey(reftable.c.id))
|
||||
if self.url.startswith('sqlite'):
|
||||
self.assertRaises(changeset.exceptions.NotSupportedError,
|
||||
self.assertRaises(exceptions.NotSupportedError,
|
||||
col.create, self.table)
|
||||
else:
|
||||
col.create(self.table)
|
||||
@ -189,7 +189,7 @@ class TestAddDropColumn(fixture.DB):
|
||||
def test_pk(self):
|
||||
"""Can create columns with primary key"""
|
||||
col = Column('data', Integer, nullable=False)
|
||||
self.assertRaises(changeset.exceptions.InvalidConstraintError,
|
||||
self.assertRaises(exceptions.InvalidConstraintError,
|
||||
col.create, self.table, primary_key_name=True)
|
||||
col.create(self.table, primary_key_name='data_pkey')
|
||||
|
||||
@ -228,7 +228,7 @@ class TestAddDropColumn(fixture.DB):
|
||||
@fixture.usedb(not_supported='sqlite')
|
||||
def test_unique(self):
|
||||
"""Can create columns with unique constraint"""
|
||||
self.assertRaises(changeset.exceptions.InvalidConstraintError,
|
||||
self.assertRaises(exceptions.InvalidConstraintError,
|
||||
Column('data', Integer, unique=True).create, self.table)
|
||||
col = Column('data', Integer)
|
||||
col.create(self.table, unique_name='data_unique')
|
||||
@ -249,7 +249,7 @@ class TestAddDropColumn(fixture.DB):
|
||||
@fixture.usedb()
|
||||
def test_index(self):
|
||||
"""Can create columns with indexes"""
|
||||
self.assertRaises(changeset.exceptions.InvalidConstraintError,
|
||||
self.assertRaises(exceptions.InvalidConstraintError,
|
||||
Column('data', Integer).create, self.table, index_name=True)
|
||||
col = Column('data', Integer)
|
||||
col.create(self.table, index_name='ix_data')
|
||||
@ -372,7 +372,7 @@ class TestRename(fixture.DB):
|
||||
|
||||
# Index renames
|
||||
if self.url.startswith('sqlite') or self.url.startswith('mysql'):
|
||||
self.assertRaises(changeset.exceptions.NotSupportedError,
|
||||
self.assertRaises(exceptions.NotSupportedError,
|
||||
self.index.rename, index_name2)
|
||||
else:
|
||||
assert_index_name(index_name1)
|
||||
|
@ -5,8 +5,8 @@ from sqlalchemy import *
|
||||
from sqlalchemy.util import *
|
||||
from sqlalchemy.exc import *
|
||||
|
||||
from migrate.exceptions import *
|
||||
from migrate.changeset import *
|
||||
from migrate.changeset.exceptions import *
|
||||
|
||||
from migrate.tests import fixture
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from migrate.exceptions import *
|
||||
from migrate.versioning import api
|
||||
from migrate.versioning.exceptions import *
|
||||
|
||||
from migrate.tests.fixture.pathed import *
|
||||
from migrate.tests.fixture import models
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
import os
|
||||
|
||||
from migrate.exceptions import *
|
||||
from migrate.versioning.genmodel import *
|
||||
from migrate.versioning.exceptions import *
|
||||
|
||||
from migrate.tests import fixture
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from migrate.versioning import exceptions
|
||||
from migrate import exceptions
|
||||
from migrate.versioning.repository import *
|
||||
from migrate.versioning.script import *
|
||||
from nose.tools import raises
|
||||
|
@ -4,8 +4,9 @@
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from migrate import exceptions
|
||||
from migrate.versioning.schema import *
|
||||
from migrate.versioning import script, exceptions, schemadiff
|
||||
from migrate.versioning import script, schemadiff
|
||||
|
||||
from sqlalchemy import *
|
||||
|
||||
|
@ -12,9 +12,9 @@ except ImportError:
|
||||
from sqlalchemy import MetaData, Table
|
||||
from nose.plugins.skip import SkipTest
|
||||
|
||||
from migrate.exceptions import *
|
||||
from migrate.versioning.repository import Repository
|
||||
from migrate.versioning import genmodel, shell, api
|
||||
from migrate.versioning.exceptions import *
|
||||
from migrate.tests.fixture import Shell, DB, usedb
|
||||
from migrate.tests.fixture import models
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from migrate.exceptions import *
|
||||
from migrate.versioning.version import *
|
||||
from migrate.versioning.exceptions import *
|
||||
|
||||
from migrate.tests import fixture
|
||||
|
||||
|
@ -29,7 +29,8 @@ import sys
|
||||
import inspect
|
||||
import logging
|
||||
|
||||
from migrate.versioning import (exceptions, repository, schema, version,
|
||||
from migrate import exceptions
|
||||
from migrate.versioning import (repository, schema, version,
|
||||
script as script_) # command name conflict
|
||||
from migrate.versioning.util import catch_known_errors, with_engine
|
||||
|
||||
|
@ -6,7 +6,7 @@ import os
|
||||
import shutil
|
||||
import logging
|
||||
|
||||
from migrate.versioning import exceptions
|
||||
from migrate import exceptions
|
||||
from migrate.versioning.config import *
|
||||
from migrate.versioning.util import KeyedInstance
|
||||
|
||||
|
@ -9,7 +9,8 @@ import logging
|
||||
from pkg_resources import resource_filename
|
||||
from tempita import Template as TempitaTemplate
|
||||
|
||||
from migrate.versioning import exceptions, version, pathed, cfgparse
|
||||
from migrate import exceptions
|
||||
from migrate.versioning import version, pathed, cfgparse
|
||||
from migrate.versioning.template import Template
|
||||
from migrate.versioning.config import *
|
||||
|
||||
@ -86,7 +87,7 @@ class Repository(pathed.Pathed):
|
||||
"""
|
||||
Ensure the target path is a valid repository.
|
||||
|
||||
:raises: :exc:`InvalidRepositoryError <migrate.versioning.exceptions.InvalidRepositoryError>`
|
||||
:raises: :exc:`InvalidRepositoryError <migrate.exceptions.InvalidRepositoryError>`
|
||||
"""
|
||||
# Ensure the existence of required files
|
||||
try:
|
||||
|
@ -10,7 +10,8 @@ from sqlalchemy.sql import and_
|
||||
from sqlalchemy import exceptions as sa_exceptions
|
||||
from sqlalchemy.sql import bindparam
|
||||
|
||||
from migrate.versioning import exceptions, genmodel, schemadiff
|
||||
from migrate import exceptions
|
||||
from migrate.versioning import genmodel, schemadiff
|
||||
from migrate.versioning.repository import Repository
|
||||
from migrate.versioning.util import load_model
|
||||
from migrate.versioning.version import VerNum
|
||||
|
@ -2,8 +2,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import logging
|
||||
|
||||
from migrate import exceptions
|
||||
from migrate.versioning.config import operations
|
||||
from migrate.versioning import pathed, exceptions
|
||||
from migrate.versioning import pathed
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -33,7 +34,7 @@ class BaseScript(pathed.Pathed):
|
||||
"""Ensure this is a valid script
|
||||
This version simply ensures the script file's existence
|
||||
|
||||
:raises: :exc:`InvalidScriptError <migrate.versioning.exceptions.InvalidScriptError>`
|
||||
:raises: :exc:`InvalidScriptError <migrate.exceptions.InvalidScriptError>`
|
||||
"""
|
||||
try:
|
||||
cls.require_found(path)
|
||||
|
@ -7,12 +7,12 @@ import logging
|
||||
from StringIO import StringIO
|
||||
|
||||
import migrate
|
||||
from migrate.versioning import exceptions, genmodel, schemadiff
|
||||
from migrate import exceptions
|
||||
from migrate.versioning import genmodel, schemadiff
|
||||
from migrate.versioning.config import operations
|
||||
from migrate.versioning.template import Template
|
||||
from migrate.versioning.script import base
|
||||
from migrate.versioning.util import import_path, load_model, with_engine
|
||||
from migrate.changeset.exceptions import *
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -89,7 +89,7 @@ class PythonScript(base.BaseScript):
|
||||
|
||||
:param path: Script location
|
||||
:type path: string
|
||||
:raises: :exc:`InvalidScriptError <migrate.versioning.exceptions.InvalidScriptError>`
|
||||
:raises: :exc:`InvalidScriptError <migrate.exceptions.InvalidScriptError>`
|
||||
:returns: Python module
|
||||
"""
|
||||
# Try to import and get the upgrade() func
|
||||
@ -141,7 +141,7 @@ class PythonScript(base.BaseScript):
|
||||
script_func(engine)
|
||||
except TypeError:
|
||||
warnings.warn("upgrade/downgrade functions must accept engine"
|
||||
" parameter (since version > 0.5.4)", MigrateDeprecationWarning)
|
||||
" parameter (since version > 0.5.4)", exceptions.MigrateDeprecationWarning)
|
||||
raise
|
||||
|
||||
@property
|
||||
|
@ -8,7 +8,8 @@ import inspect
|
||||
import logging
|
||||
from optparse import OptionParser, BadOptionError
|
||||
|
||||
from migrate.versioning import api, exceptions
|
||||
from migrate import exceptions
|
||||
from migrate.versioning import api
|
||||
from migrate.versioning.config import *
|
||||
from migrate.versioning.util import asbool
|
||||
|
||||
|
@ -11,11 +11,10 @@ from sqlalchemy import create_engine
|
||||
from sqlalchemy.engine import Engine
|
||||
from sqlalchemy.pool import StaticPool
|
||||
|
||||
from migrate.versioning import exceptions
|
||||
from migrate import exceptions
|
||||
from migrate.versioning.util.keyedinstance import KeyedInstance
|
||||
from migrate.versioning.util.importpath import import_path
|
||||
|
||||
from migrate.changeset import *
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -31,7 +30,7 @@ def load_model(dotted_name):
|
||||
if ':' not in dotted_name:
|
||||
# backwards compatibility
|
||||
warnings.warn('model should be in form of module.model:User '
|
||||
'and not module.model.User', MigrateDeprecationWarning)
|
||||
'and not module.model.User', exceptions.MigrateDeprecationWarning)
|
||||
dotted_name = ':'.join(dotted_name.rsplit('.', 1))
|
||||
return EntryPoint.parse('x=%s' % dotted_name).load(False)
|
||||
else:
|
||||
@ -127,7 +126,7 @@ def construct_engine(engine, **opts):
|
||||
if echo:
|
||||
warnings.warn('echo=True parameter is deprecated, pass '
|
||||
'engine_arg_echo=True or engine_dict={"echo": True}',
|
||||
MigrateDeprecationWarning)
|
||||
exceptions.MigrateDeprecationWarning)
|
||||
kwargs['echo'] = echo
|
||||
|
||||
# parse keyword arguments
|
||||
|
@ -6,7 +6,8 @@ import re
|
||||
import shutil
|
||||
import logging
|
||||
|
||||
from migrate.versioning import exceptions, pathed, script
|
||||
from migrate import exceptions
|
||||
from migrate.versioning import pathed, script
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
Loading…
x
Reference in New Issue
Block a user