diff --git a/navipy/database/__init__.py b/navipy/database/__init__.py index b3107011db03e6fec88488956618bf6750f9bd44..ac02d211d334f4698852cf97a69ebe0d72200fe7 100644 --- a/navipy/database/__init__.py +++ b/navipy/database/__init__.py @@ -116,8 +116,10 @@ It creates three sql table on initialisation. def __init__(self, filename, channels=['R', 'G', 'B', 'D']): """Initialisation of the database """ - assert isinstance(filename, str), 'filename should be a string' - assert isinstance(channels, list), 'nb_channel should be an integer' + if not isinstance(filename, str): + raise TypeError('filename should be a string') + if not isinstance(channels, list): + raise TypeError('nb_channel should be an integer') self.filename = filename self.channels = channels self.normalisation_columns = list() @@ -151,7 +153,7 @@ It creates three sql table on initialisation. assert self.table_exist(tablename),\ '{} does not contain a table named {}'.format( filename, tablename) - elif self.create(): + elif self.create: # Create database self.db = sqlite3.connect( filename, detect_types=sqlite3.PARSE_DECLTYPES) @@ -244,7 +246,7 @@ It creates three sql table on initialisation. WHERE {}; """.format(where), params) return self.db_cursor.fetchone()[0] - elif self.create(): + elif self.create: self.db_cursor.execute( """ INSERT @@ -264,6 +266,7 @@ It creates three sql table on initialisation. print(posorient) raise ValueError('posorient not found') + @property def create(self): return False @@ -276,6 +279,7 @@ class DataBaseLoad(DataBase): """Initialise the DataBaseLoader""" DataBase.__init__(self, filename, channels=channels) + @property def create(self): """use to decide weather to alter the database or not return False because we do not want @@ -300,7 +304,8 @@ class DataBaseLoad(DataBase): toyield.drop('id', inplace=True) yield toyield - def get_posorients(self): + @property + def posorients(self): """Return the position orientations of all points in the \ database """