예제 #1
0
def print_all_db():
    print('Open databases: {}'.format(core_api.get_databases_count()))

    for filename in core_api.get_open_databases():
        print_db(filename)

    print_memory_db()
예제 #2
0
def print_all_db():
    print('Open databases: {}'.format(core_api.get_databases_count()))

    for filename in core_api.get_open_databases():
        print_db(filename)

    print_memory_db()
예제 #3
0
파일: __init__.py 프로젝트: xguse/outspline
    def find_in_tree(self):
        sel = self.listview.GetFirstSelected()

        if sel > -1:
            for filename in core_api.get_open_databases():
                wxgui_api.unselect_all_items(filename)

            seldb = None
            warning = False

            # [1]: line repeated in the loop because of
            # wxgui_api.select_database_tab
            filename, id_ = self.itemdatamap[self.listview.GetItemData(sel)]

            while True:
                # It's necessary to repeat this line (see [1]) because
                # wxgui_api.select_database_tab must be executed only once
                # for the first selected item
                filename, id_ = self.itemdatamap[self.listview.GetItemData(
                                                                        sel)]

                # Check whether the database is still open and the item
                # still exists because the search results are retrieved in
                # a separate thread and are not updated together with the
                # database
                if core_api.is_database_open(filename) and \
                                        core_api.is_item(filename, id_):
                    wxgui_api.add_item_to_selection(filename, id_)

                    if seldb is None:
                        seldb = filename
                else:
                    warning = True

                sel = self.listview.GetNextSelected(sel)

                if sel < 0:
                    break

            if seldb:
                wxgui_api.select_database_tab(seldb)

                if warning:
                    msgboxes.some_items_not_found().ShowModal()
            elif warning:
                msgboxes.all_items_not_found().ShowModal()
예제 #4
0
    def find_in_tree(self):
        sel = self.listview.GetFirstSelected()

        if sel > -1:
            for filename in core_api.get_open_databases():
                wxgui_api.unselect_all_items(filename)

            seldb = None
            warning = False

            # [1]: line repeated in the loop because of
            # wxgui_api.select_database_tab
            filename, id_ = self.itemdatamap[self.listview.GetItemData(sel)]

            while True:
                # It's necessary to repeat this line (see [1]) because
                # wxgui_api.select_database_tab must be executed only once
                # for the first selected item
                filename, id_ = self.itemdatamap[self.listview.GetItemData(
                    sel)]

                # Check whether the database is still open and the item
                # still exists because the search results are retrieved in
                # a separate thread and are not updated together with the
                # database
                if core_api.is_database_open(filename) and \
                                        core_api.is_item(filename, id_):
                    wxgui_api.add_item_to_selection(filename, id_)

                    if seldb is None:
                        seldb = filename
                else:
                    warning = True

                sel = self.listview.GetNextSelected(sel)

                if sel < 0:
                    break

            if seldb:
                wxgui_api.select_database_tab(seldb)

                if warning:
                    msgboxes.some_items_not_found().ShowModal()
            elif warning:
                msgboxes.all_items_not_found().ShowModal()
예제 #5
0
파일: __init__.py 프로젝트: xguse/outspline
    def _finish_search_restart(self):
        self._set_tab_icon_ongoing()

        string = self.filters.text.GetValue()
        self._set_title(string)

        if not self.filters.option4.GetValue():
            string = re.escape(string)

        self.results.reset()
        self.search_threaded_action = self._search_threaded_continue
        self.finish_search_action = self._finish_search_dummy

        flags = re.MULTILINE

        if not self.filters.option5.GetValue():
            flags |= re.IGNORECASE

        try:
            regexp = re.compile(string, flags)
        except re.error:
            msgboxes.bad_regular_expression().ShowModal()
            self.finish_search()
        else:
            # Note that the databases are released *before* the threads are
            # terminated: this is safe as no more calls to the databases are
            # made after core_api.get_all_items_text in
            # self._finish_search_restart_database
            if core_api.block_databases():
                if self.filters.option1.GetValue():
                    filename = wxgui_api.get_selected_database_filename()
                    self._finish_search_restart_database(filename, regexp)
                else:
                    for filename in core_api.get_open_databases():
                        self._finish_search_restart_database(filename, regexp)

                # Note that the databases are released *before* the threads are
                # terminated: this is safe as no more calls to the databases
                # are made after core_api.get_all_items_text in
                # self._finish_search_restart_database
                core_api.release_databases()
            else:
                self.finish_search()
예제 #6
0
    def _finish_search_restart(self):
        self._set_tab_icon_ongoing()

        string = self.filters.text.GetValue()
        self._set_title(string)

        if not self.filters.option4.GetValue():
            string = re.escape(string)

        self.results.reset()
        self.search_threaded_action = self._search_threaded_continue
        self.finish_search_action = self._finish_search_dummy

        flags = re.MULTILINE

        if not self.filters.option5.GetValue():
            flags |= re.IGNORECASE

        try:
            regexp = re.compile(string, flags)
        except re.error:
            msgboxes.bad_regular_expression().ShowModal()
            self.finish_search()
        else:
            # Note that the databases are released *before* the threads are
            # terminated: this is safe as no more calls to the databases are
            # made after core_api.get_all_items_text in
            # self._finish_search_restart_database
            if core_api.block_databases():
                if self.filters.option1.GetValue():
                    filename = wxgui_api.get_selected_database_filename()
                    self._finish_search_restart_database(filename, regexp)
                else:
                    for filename in core_api.get_open_databases():
                        self._finish_search_restart_database(filename, regexp)

                # Note that the databases are released *before* the threads are
                # terminated: this is safe as no more calls to the databases
                # are made after core_api.get_all_items_text in
                # self._finish_search_restart_database
                core_api.release_databases()
            else:
                self.finish_search()
예제 #7
0
파일: __init__.py 프로젝트: xguse/outspline
    def reset_print_menu(self):
        self.DestroyId(self.ID_PRINT)

        self.printtb = wx.Menu()
        self.PrependMenu(self.ID_PRINT, "Print &databases", self.printtb)

        self.all_ = self.printtb.Append(self.ID_PRINT_ALL, 'All databases')
        wxgui_api.bind_to_menu(self.print_all_databases, self.all_)

        self.printtb.AppendSeparator()

        self.databases = {}

        for filename in core_api.get_open_databases():
            # Note that these IDs will grow progressively every time this menu
            # is reset, UNTIL THE INTERNAL ID LIMIT FOR MENU ITEMS!!!
            # (Then, crash...)
            TEMP_ID_MENU = wx.NewId()
            TEMP_ID_ALL = wx.NewId()

            self.databases[filename] = {
                'menu': wx.Menu(),
                'all_': None,
                'tables': {}
            }

            self.printtb.AppendMenu(TEMP_ID_MENU, _os.path.basename(filename),
                                    self.databases[filename]['menu'])

            self.databases[filename]['all_'] = self.databases[filename][
                                    'menu'].Append(TEMP_ID_ALL, 'All tables')
            wxgui_api.bind_to_menu(self.print_all_tables_loop(filename),
                                   self.databases[filename]['all_'])

            self.databases[filename]['menu'].AppendSeparator()

            for table in core_api.select_all_table_names(filename):
                # Note that these IDs will grow progressively every time this
                # menu is reset, UNTIL THE INTERNAL ID LIMIT FOR MENU ITEMS!!!
                # (Then, crash...)
                TEMP_ID = wx.NewId()
                self.databases[filename]['tables'][table[0]] = \
                                    self.databases[filename]['menu'].Append(
                                    TEMP_ID, table[0])
                wxgui_api.bind_to_menu(self.print_table_loop(filename,
                                table[0]),
                                self.databases[filename]['tables'][table[0]])

        if self.databases:
            self.printtb.AppendSeparator()

        self.memory = {
            'menu': wx.Menu(),
            'all_': None,
            'tables': {}
        }

        self.printtb.AppendMenu(self.ID_PRINT_MEMORY, ':memory:',
                                                        self.memory['menu'])

        self.memory['all_'] = self.memory['menu'].Append(
                                        self.ID_PRINT_MEMORY_ALL, 'All tables')
        wxgui_api.bind_to_menu(self.print_all_memory_tables,
                                                        self.memory['all_'])

        self.memory['menu'].AppendSeparator()

        for table in core_api.select_all_memory_table_names():
            # Note that these IDs will grow progressively every time this menu
            # is reset, UNTIL THE INTERNAL ID LIMIT FOR MENU ITEMS!!!
            # (Then, crash...)
            TEMP_ID = wx.NewId()
            self.memory['tables'][table[0]] = self.memory['menu'].Append(
                                                            TEMP_ID, table[0])
            wxgui_api.bind_to_menu(self.print_memory_table_loop(table[0]),
                                   self.memory['tables'][table[0]])
예제 #8
0
파일: __init__.py 프로젝트: xguse/outspline
    def reset_print_menu(self):
        self.DestroyId(self.ID_PRINT)

        self.printtb = wx.Menu()
        self.PrependMenu(self.ID_PRINT, "Print &databases", self.printtb)

        self.all_ = self.printtb.Append(self.ID_PRINT_ALL, 'All databases')
        wxgui_api.bind_to_menu(self.print_all_databases, self.all_)

        self.printtb.AppendSeparator()

        self.databases = {}

        for filename in core_api.get_open_databases():
            # Note that these IDs will grow progressively every time this menu
            # is reset, UNTIL THE INTERNAL ID LIMIT FOR MENU ITEMS!!!
            # (Then, crash...)
            TEMP_ID_MENU = wx.NewId()
            TEMP_ID_ALL = wx.NewId()

            self.databases[filename] = {
                'menu': wx.Menu(),
                'all_': None,
                'tables': {}
            }

            self.printtb.AppendMenu(TEMP_ID_MENU, _os.path.basename(filename),
                                    self.databases[filename]['menu'])

            self.databases[filename]['all_'] = self.databases[filename][
                'menu'].Append(TEMP_ID_ALL, 'All tables')
            wxgui_api.bind_to_menu(self.print_all_tables_loop(filename),
                                   self.databases[filename]['all_'])

            self.databases[filename]['menu'].AppendSeparator()

            for table in core_api.select_all_table_names(filename):
                # Note that these IDs will grow progressively every time this
                # menu is reset, UNTIL THE INTERNAL ID LIMIT FOR MENU ITEMS!!!
                # (Then, crash...)
                TEMP_ID = wx.NewId()
                self.databases[filename]['tables'][table[0]] = \
                                    self.databases[filename]['menu'].Append(
                                    TEMP_ID, table[0])
                wxgui_api.bind_to_menu(
                    self.print_table_loop(filename, table[0]),
                    self.databases[filename]['tables'][table[0]])

        if self.databases:
            self.printtb.AppendSeparator()

        self.memory = {'menu': wx.Menu(), 'all_': None, 'tables': {}}

        self.printtb.AppendMenu(self.ID_PRINT_MEMORY, ':memory:',
                                self.memory['menu'])

        self.memory['all_'] = self.memory['menu'].Append(
            self.ID_PRINT_MEMORY_ALL, 'All tables')
        wxgui_api.bind_to_menu(self.print_all_memory_tables,
                               self.memory['all_'])

        self.memory['menu'].AppendSeparator()

        for table in core_api.select_all_memory_table_names():
            # Note that these IDs will grow progressively every time this menu
            # is reset, UNTIL THE INTERNAL ID LIMIT FOR MENU ITEMS!!!
            # (Then, crash...)
            TEMP_ID = wx.NewId()
            self.memory['tables'][table[0]] = self.memory['menu'].Append(
                TEMP_ID, table[0])
            wxgui_api.bind_to_menu(self.print_memory_table_loop(table[0]),
                                   self.memory['tables'][table[0]])