Changeset 4446

Show
Ignore:
Timestamp:
04/05/09 15:14:47 (4 years ago)
Author:
gpolo
Message:

Be more explicit about missing files.

Location:
trunk/umit/merger
Files:
1 added
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/umit/merger/merge_ini.py

    r4437 r4446  
    22import shutil 
    33import ConfigParser 
     4 
     5from umit.merger.errors import OriginError, DestinationError 
    46 
    57def merge(from_file, to_file): 
     
    911    @return true or false 
    1012    """ 
    11     if not os.path.exists(from_file) or not os.path.exists(to_file): 
    12         return False 
     13    if not os.path.exists(from_file): 
     14        raise OriginError(from_file) 
     15    if not os.path.exists(to_file): 
     16        raise DestinationError(to_file) 
    1317 
    1418    # Read new file 
     
    4347        config.write(f) 
    4448 
    45     return True 
    46  
    4749def copy_section(config, config_new, section): 
    4850    config.add_section(section) 
  • trunk/umit/merger/sqlitedb.py

    r4432 r4446  
    99except ImportError: 
    1010    from pysqlite2 import dbapi2 as sqlite 
     11 
     12from umit.merger.errors import OriginError, DestinationError 
    1113 
    1214def _dict_factory(cursor, row): 
     
    154156 
    155157    def _merge(self): 
     158        if not os.path.isfile(self._fromdb): 
     159            raise OriginError("%r is not a file." % self._fromdb) 
     160 
    156161        new = sqlite.connect(self._fromdb) 
    157162        self._fromcursor = new_cursor = new.cursor(_DictCursor) 
    158163 
    159164        if not os.path.isfile(self._todb): 
    160             raise Exception("The older db %r is not a file." % self._todb) 
     165            raise DestinationError("%r is not a file." % self._todb) 
    161166 
    162167        old = sqlite.connect(self._todb) 
  • trunk/umit/merger/tests/test_sqlitemerge.py

    r4431 r4446  
    33from test.test_support import run_unittest 
    44 
    5 from sqlitedb import sqlite, merge, column_definitions, _DictCursor 
     5from umit.merger.sqlitedb import sqlite, merge, column_definitions, _DictCursor 
    66 
    77def conn_cursor(name):