def copy_items(self, event): filename = wxgui_api.get_selected_database_filename() # This method may be launched by the menu accelerator, but the database # database may not be open if filename: self.dbs[filename].copy_items()
def get_selected_log(self): filename = wxgui_api.get_selected_database_filename() try: return self.alarmlogs[filename] except KeyError: return False
def paste_items_as_children(self, event, no_confirm=False): filename = wxgui_api.get_selected_database_filename() # This method may be launched by the menu accelerator, but the database # database may not be open if filename: self.dbs[filename].paste_items_as_children(no_confirm=no_confirm)
def get_selected_log(self): filename = wxgui_api.get_selected_database_filename() try: return self.alarmlogs[filename] except KeyError: return False
def paste_items_as_children(self, event, no_confirm=False): filename = wxgui_api.get_selected_database_filename() # This method may be launched by the menu accelerator, but the database # database may not be open if filename: self.dbs[filename].paste_items_as_children(no_confirm=no_confirm)
def copy_items(self, event): filename = wxgui_api.get_selected_database_filename() # This method may be launched by the menu accelerator, but the database # database may not be open if filename: self.dbs[filename].copy_items()
def link_to_selection(self): filename = wxgui_api.get_selected_database_filename() if filename: selection = wxgui_api.get_tree_selections(filename, none=False, many=False) if selection: self.target = wxgui_api.get_tree_item_id(filename, selection[0])
def link_to_selection(self): filename = wxgui_api.get_selected_database_filename() if filename: selection = wxgui_api.get_tree_selections(filename, none=False, many=False) if selection: self.target = wxgui_api.get_tree_item_id(filename, selection[0])
def populate_tree(self, event): if core_api.block_databases(): filename = wxgui_api.get_selected_database_filename() # This method may be launched even if no database is open if filename: group = core_api.get_next_history_group(filename) description = 'Populate tree' i = 0 while i < 10: dbitems = core_api.get_items_ids(filename) try: itemid = random.choice(dbitems) except IndexError: # No items in the database yet itemid = 0 mode = 'child' else: mode = random.choice(('child', 'sibling')) # See the comment in wxgui.tree.expand_item_ancestors # for the reason why calling this method is necessary wxgui_api.expand_item_ancestors(filename, itemid) text = self._populate_tree_text() id_ = self._populate_tree_item(mode, filename, itemid, group, text, description) # It should also be checked if the database supports # organism_basicrules (bug #330) if organism_api and wxscheduler_basicrules_api and \ filename in \ organism_api.get_supported_open_databases(): self._populate_tree_rules(filename, id_, group, description) if links_api and wxlinks_api and len(dbitems) > 0 and \ filename in \ links_api.get_supported_open_databases(): self._populate_tree_link(filename, id_, dbitems, group, description) i += 1 wxgui_api.refresh_history(filename) core_api.release_databases()
def populate_tree(self, event): if core_api.block_databases(): filename = wxgui_api.get_selected_database_filename() # This method may be launched even if no database is open if filename: group = core_api.get_next_history_group(filename) description = 'Populate tree' i = 0 while i < 10: dbitems = core_api.get_items_ids(filename) try: itemid = random.choice(dbitems) except IndexError: # No items in the database yet itemid = 0 mode = 'child' else: mode = random.choice(('child', 'sibling')) # See the comment in wxgui.tree.expand_item_ancestors # for the reason why calling this method is necessary wxgui_api.expand_item_ancestors(filename, itemid) text = self._populate_tree_text() id_ = self._populate_tree_item(mode, filename, itemid, group, text, description) # It should also be checked if the database supports # organism_basicrules (bug #330) if organism_api and wxscheduler_basicrules_api and \ filename in \ organism_api.get_supported_open_databases(): self._populate_tree_rules(filename, id_, group, description) if links_api and wxlinks_api and len(dbitems) > 0 and \ filename in \ links_api.get_supported_open_databases(): self._populate_tree_link(filename, id_, dbitems, group, description) i += 1 wxgui_api.refresh_history(filename) core_api.release_databases()
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()
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()
def _select_items(many): filename = wxgui_api.get_selected_database_filename() ids = core_api.get_items_ids(filename) if ids: w = 0 if many else 1 modes = ((40, 80)[w] * ['select_one'] + (10, 0)[w] * ['reselect_many'] + (10, 0)[w] * ['select_some'] + (10, 0)[w] * ['select_all'] + (20, 0)[w] * ['unselect_some'] + (10, 20)[w] * ['unselect_all']) mode = random.choice(modes) if mode == 'unselect_some': selection = wxgui_api.get_tree_selections(filename) if selection: sids = [ wxgui_api.get_tree_item_id(filename, i) for i in selection ] remids = random.sample(ids, random.randint(1, len(ids))) wxgui_api.simulate_remove_items_from_selection( filename, remids) else: if mode in ('select_one', 'reselect_many', 'unselect_all'): wxgui_api.simulate_unselect_all_items(filename) addids = { 'select_one': (random.choice(ids), ), 'reselect_many': random.sample( ids, random.randint(2 if len(ids) > 1 else 1, len(ids))), 'select_some': random.sample(ids, random.randint(1, len(ids))), 'select_all': ids, 'unselect_all': (), } wxgui_api.simulate_add_items_to_selection(filename, addids[mode]) return wxgui_api.get_tree_selections(filename)
def _select_items(many): filename = wxgui_api.get_selected_database_filename() ids = core_api.get_items_ids(filename) if ids: w = 0 if many else 1 modes = ( (40, 80)[w] * ['select_one'] + (10, 0)[w] * ['reselect_many'] + (10, 0)[w] * ['select_some'] + (10, 0)[w] * ['select_all'] + (20, 0)[w] * ['unselect_some'] + (10, 20)[w] * ['unselect_all'] ) mode = random.choice(modes) if mode == 'unselect_some': selection = wxgui_api.get_tree_selections(filename) if selection: sids = [wxgui_api.get_tree_item_id(filename, i) for i in selection] remids = random.sample(ids, random.randint(1, len(ids))) wxgui_api.simulate_remove_items_from_selection(filename, remids) else: if mode in ('select_one', 'reselect_many', 'unselect_all'): wxgui_api.simulate_unselect_all_items(filename) addids = { 'select_one': (random.choice(ids), ), 'reselect_many': random.sample(ids, random.randint( 2 if len(ids) > 1 else 1, len(ids))), 'select_some': random.sample(ids, random.randint(1, len(ids))), 'select_all': ids, 'unselect_all': (), } wxgui_api.simulate_add_items_to_selection(filename, addids[mode]) return wxgui_api.get_tree_selections(filename)