Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _post_init(self):
for o in self.savedession:
filename = self.savedession[o]
databases.open_database(filename)
try:
wx.GetApp().nb_left.select_page(0)
except IndexError:
pass
# Bind *after* opening the databases in the session, because the
# session must be refreshed only when databases are opened manually
databases.open_database_event.bind(self._handle_open_database)
databases.close_database_event.bind(self._handle_close_database)
def open_database(self, event, filename=None):
if core_api.block_databases():
databases.open_database(filename)
core_api.release_databases()
def new_database(self, event, filename=None):
if core_api.block_databases():
fn = databases.create_database(filename=filename)
if fn:
databases.open_database(fn)
core_api.release_databases()
# the dialogs to save the database
self.propmanager.close(self.filename)
if databases.close_database(self.filename):
shutil.copy2(self.filename, self.backup.GetPath())
if self.value == 0:
dbdeps.Database(self.filename).add((self.ext, ))
elif self.value == 1:
dbdeps.Database(self.filename).remove((self.ext, ))
else:
dbdeps.Database(self.filename).remove((self.ext, ),
ignored=True)
# Use CallAfter or segfaults may happen
wx.CallAfter(databases.open_database, self.filename,
open_properties=True)
# Note that no other operation should be done on the database
# directly here, because opening the database may fail e.g.
# because of the compatibility checks
else:
self.propmanager.open(self.filename)
# Always close the dialog because the property settings have been
# reset by closing and reopening the property tab
self._close()
def _skip(self, event):
self._close()
# Use CallAfter or segfaults may happen e.g. if re-opening after
# changing the dependencies in the properties tab
wx.CallAfter(databases.open_database, self.updater.get_filename(),
check_new_extensions=False,
open_properties=self.open_properties)
def _add(self, event):
filename = self.updater.get_filename()
shutil.copy2(filename, self.backup.GetPath())
dbdeps.Database(filename).add(self.deplist)
self._close()
# Use CallAfter or segfaults may happen e.g. if re-opening after
# changing the dependencies in the properties tab
wx.CallAfter(databases.open_database, filename,
open_properties=self.open_properties)