pgtoolkit/pgdiff.py
changeset 61 703bba757605
parent 60 bb6b20106ff5
child 63 8c7f0a51ba50
equal deleted inserted replaced
60:bb6b20106ff5 61:703bba757605
    24 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    24 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    25 # THE SOFTWARE.
    25 # THE SOFTWARE.
    26 
    26 
    27 
    27 
    28 from pgtoolkit.highlight import *
    28 from pgtoolkit.highlight import *
       
    29 
       
    30 
       
    31 class PgDiffError(Exception):
       
    32     pass
    29 
    33 
    30 
    34 
    31 class DiffBase:
    35 class DiffBase:
    32     COLORS = {
    36     COLORS = {
    33         '+' : BOLD | GREEN,
    37         '+' : BOLD | GREEN,
   474         include (list) -- if not empty, consider only these schemas for diff
   478         include (list) -- if not empty, consider only these schemas for diff
   475         exclude (list) -- exclude these schemas from diff
   479         exclude (list) -- exclude these schemas from diff
   476 
   480 
   477         Order: include, exclude
   481         Order: include, exclude
   478         include=[] means include everything
   482         include=[] means include everything
       
   483 
       
   484         Raises:
       
   485             PgDiffError: when schema from include list is not found in src db
       
   486 
   479         '''
   487         '''
       
   488         for schema in include:
       
   489             self._check_schema_exist(schema)
   480         self.include_schemas.clear()
   490         self.include_schemas.clear()
   481         self.include_schemas.update(include)
   491         self.include_schemas.update(include)
   482         self.exclude_schemas.clear()
   492         self.exclude_schemas.clear()
   483         self.exclude_schemas.update(exclude)
   493         self.exclude_schemas.update(exclude)
   484 
   494 
   487         self.include_tables.clear()
   497         self.include_tables.clear()
   488         self.include_tables.update(include)
   498         self.include_tables.update(include)
   489         self.exclude_tables.clear()
   499         self.exclude_tables.clear()
   490         self.exclude_tables.update(exclude)
   500         self.exclude_tables.update(exclude)
   491 
   501 
       
   502 
       
   503     def _check_schema_exist(self, schema):
       
   504         if not schema in self.src.schemas:
       
   505             raise PgDiffError('Schema "%s" not found in source database.' % schema)
       
   506