def _dispatch(self, method, params): args = [] kwargs = {} for param in params: if isinstance(param, dict): kwargs.update(param) else: args.append(param) func = None # Look up method from keywords first if method == "ping": return "pong" elif method in keywords.get_command_keywords(): func = keywords.get_command_keywords()[method][0] elif hasattr(cmd, method): func = getattr(cmd, method) elif method.startswith("preset.") or method.startswith("util."): module, function = method.split(".") if module in MODULES and hasattr(MODULES[module], function): func = getattr(MODULES[module], function) if not callable(func): raise ValueError("{} is not callable".format(method)) result = func(*args, **kwargs) if result is None: result = -1 return result
def get_menu(self, arg): if arg == '_commands': from pymol import keywords from pymol.helping import python_help return [[ 1, str(command), self.varname + f'.set_command({command!r})' ] for (command, value) in keywords.get_command_keywords().items() if not command.startswith('_') and value[0] != python_help] if arg not in self.menu: return None try: sc = self.shortcut[arg]() self.set_menu_values(arg, sc.keywords[:20]) except KeyError: pass return self.menu[arg]
def __init__(self, _pymol, _COb): # store parent self._pymol = _pymol # store C object for easy access self._COb = _COb # private data self.color_sc = None self.reaper = None # CONSTANTS (pymol/constants.py) self.DEFAULT_ERROR = global_cmd.DEFAULT_ERROR self.DEFAULT_SUCCESS = global_cmd.DEFAULT_SUCCESS self.QuietException = global_cmd.QuietException self.Shortcut = global_cmd.Shortcut self._load2str = global_cmd._load2str self.boolean_dict = global_cmd.boolean_dict self.boolean_sc = global_cmd.boolean_sc self.fb_action = global_cmd.fb_action self.fb_mask = global_cmd.fb_mask self.fb_module = global_cmd.fb_module self.fb_debug = global_cmd.fb_debug # this cannot be right... self.file_ext_re = global_cmd.file_ext_re self.gz_ext_re = global_cmd.gz_ext_re self.loadable = global_cmd.loadable self.nt_hidden_path_re = global_cmd.nt_hidden_path_re self.palette_dict = global_cmd.palette_dict self.palette_sc = global_cmd.palette_sc self.parsing = global_cmd.parsing self.quote_alpha_list_re = global_cmd.quote_alpha_list_re self.repres = global_cmd.repres self.repres_sc = global_cmd.repres_sc self.safe_alpha_list_eval = global_cmd.safe_alpha_list_eval self.safe_list_eval = global_cmd.safe_list_eval self.safe_oname_re = global_cmd.safe_oname_re self.sanitize_alpha_list_re = global_cmd.sanitize_alpha_list_re self.sanitize_list_re = global_cmd.sanitize_list_re self.space_sc = global_cmd.space_sc self.stereo_dict = global_cmd.stereo_dict self.stereo_sc = global_cmd.stereo_sc self.toggle_dict = global_cmd.toggle_dict self.toggle_sc = global_cmd.toggle_sc self.window_dict = global_cmd.window_dict self.window_sc = global_cmd.window_sc # GLOBAL FUNCTIONS self.exp_path = global_cmd.exp_path # deferred initiailization global_cmd._deferred_init_pymol_internals(_pymol) # PRIVATE FUNCTIONS (requiring '_self' as a keyword argument) # locking.py self.reaper = None if 1: # use own locks (for performance) self.lock_api = _pymol.lock_api self.lock_api_c = _pymol.lock_api_c self.lock_api_data = _pymol.lock_api_data self.lock_api_glut = _pymol.lock_api_glut self.lock_api_status = _pymol.lock_api_status else: # use global locks (for debugging) self.lock_api = global_cmd._pymol.lock_api self.lock_api_c = global_cmd._pymol.lock_api_c self.lock_api_data = global_cmd._pymol.lock_api_data self.lock_api_glut = global_cmd._pymol.lock_api_glut self.lock_api_status = global_cmd._pymol.lock_api_status self.lock_api_allow_flush = 1 self.lock_c = global_cmd.lock_c self.unlock_c = global_cmd.unlock_c self.lock_data = global_cmd.lock_data self.unlock_data = global_cmd.unlock_data self.lock_status_attempt = global_cmd.lock_status_attempt self.lock_status = global_cmd.lock_status self.unlock_status = global_cmd.unlock_status self.lock_glut = global_cmd.lock_glut self.unlock_glut = global_cmd.unlock_glut self.lock_without_glut = global_cmd.lock_without_glut self.lock = global_cmd.lock self.lock_attempt = global_cmd.lock_attempt self.unlock = global_cmd.unlock self.is_glut_thread = global_cmd.is_glut_thread self.setup_global_locks = global_cmd.setup_global_locks self.interrupt = global_cmd.interrupt self.block_flush = global_cmd.block_flush self.unblock_flush = global_cmd.unblock_flush # pymol/checking.py self._raising = global_cmd._raising self.is_dict = global_cmd.is_dict self.is_error = global_cmd.is_error self.is_list = global_cmd.is_list self.is_ok = global_cmd.is_ok self.is_sequence = global_cmd.is_sequence self.is_string = global_cmd.is_string self.is_tuple = global_cmd.is_tuple # from pymol/feedingback.py self._feedback = global_cmd._feedback # from pymol/internal.py self._adjust_coord = global_cmd._adjust_coord self._coordset_update_spawn = global_cmd._coordset_update_spawn self._coordset_update_thread = global_cmd._coordset_update_thread self._copy_image = global_cmd._copy_image self._do = global_cmd._do self._dump_floats = global_cmd._dump_floats self._dump_ufloats = global_cmd._dump_ufloats self._fake_drag = global_cmd._fake_drag self._get_color_sc = global_cmd._get_color_sc self._get_feedback = global_cmd._get_feedback self._interpret_color = global_cmd._interpret_color self._interpret_color = global_cmd._interpret_color self._invalidate_color_sc = global_cmd._invalidate_color_sc self._invalidate_color_sc = global_cmd._invalidate_color_sc self._load = global_cmd._load self._mpng = global_cmd._mpng self._object_update_spawn = global_cmd._object_update_spawn self._object_update_thread = global_cmd._object_update_thread self._png = global_cmd._png self._quit = global_cmd._quit self._ray_anti_spawn = global_cmd._ray_anti_spawn self._ray_hash_spawn = global_cmd._ray_hash_spawn self._ray_spawn = global_cmd._ray_spawn self._refresh = global_cmd._refresh self._sgi_stereo = global_cmd._sgi_stereo self._validate_color_sc = global_cmd._validate_color_sc self._cache_set = global_cmd._cache_set self._cache_get = global_cmd._cache_get self._cache_clear = global_cmd._cache_clear self._cache_mark = global_cmd._cache_mark self._cache_purge = global_cmd._cache_purge # now we create the command langauge from pymol import keywords self.keyword = keywords.get_command_keywords() self.kw_list = self.keyword.keys() keywords.fix_list(self.kw_list) self.kwhash = self.Shortcut(self.kw_list) keywords.fix_dict(self.keyword) self.controlling = pymol.controlling self.completing = pymol.completing self.controlling = pymol.controlling self.editing = pymol.editing self.exporting = pymol.exporting self.moving = pymol.moving self.creating = pymol.creating self.viewing = pymol.viewing self.setting = pymol.setting self.commanding = pymol.commanding self.help_only = keywords.get_help_only_keywords() self.help_sc = self.Shortcut(self.keyword.keys()+self.help_only.keys()) self.selection_sc = lambda sc=self.Shortcut,gn=self.get_names:sc(gn('public')+['all']) self.object_sc = lambda sc=self.Shortcut,gn=self.get_names:sc(gn('objects')) self.map_sc = lambda sc=self.Shortcut,gnot=self.get_names_of_type:sc(gnot('object:map')) self.contour_sc = lambda sc=self.Shortcut,gnot=self.get_names_of_type:sc( gnot('object:mesh')+gnot('object:surface')) self.fb_action_sc = pymol.feedingback.fb_action_sc self.fb_module_sc = pymol.feedingback.fb_module_sc self.fb_mask_sc = pymol.feedingback.fb_mask_sc self.auto_arg = pymol.completing.get_auto_arg_list(self) self.color_sc = None # keyboard configuration from pymol import keyboard self.special = keyboard.get_special(self) self.shft_special = keyboard.get_shft_special(self) self.alt_special = keyboard.get_alt_special(self) self.ctrl_special = keyboard.get_ctrl_special(self) self.ctsh_special = keyboard.get_ctsh_special(self) self.ctrl = keyboard.get_ctrl(self) self.alt = keyboard.get_alt(self)
def __init__(self, _pymol, _COb): self._weakref = weakref.ref(self) self._weakrefproxy = weakref.proxy(self) # store parent self._pymol = weakref.proxy(_pymol) # store C object for easy access self._COb = _COb # private data self.color_sc = None self.reaper = None # deferred initiailization global_cmd._deferred_init_pymol_internals(_pymol) # PRIVATE FUNCTIONS (requiring '_self' as a keyword argument) # locking.py self.reaper = None if 1: # use own locks (for performance) self.lock_api = _pymol.lock_api self.lock_api_c = _pymol.lock_api_c self.lock_api_data = _pymol.lock_api_data self.lock_api_glut = _pymol.lock_api_glut self.lock_api_status = _pymol.lock_api_status else: # use global locks (for debugging) self.lock_api = global_cmd._pymol.lock_api self.lock_api_c = global_cmd._pymol.lock_api_c self.lock_api_data = global_cmd._pymol.lock_api_data self.lock_api_glut = global_cmd._pymol.lock_api_glut self.lock_api_status = global_cmd._pymol.lock_api_status self.lock_api_allow_flush = 1 self.lockcm = global_cmd.LockCM(self) # now we create the command langauge from pymol import keywords self.keyword = keywords.get_command_keywords() self.kw_list = list(self.keyword) keywords.fix_list(self.kw_list) self.kwhash = self.Shortcut(self.kw_list) keywords.fix_dict(self.keyword) self.help_only = keywords.get_help_only_keywords() self.help_sc = self.Shortcut( itertools.chain(self.keyword, self.help_only)) self.selection_sc = lambda sc=self.Shortcut,gn=self.get_names:sc(gn('public')+['all']) self.object_sc = lambda sc=self.Shortcut,gn=self.get_names:sc(gn('objects')) self.map_sc = lambda sc=self.Shortcut,gnot=self.get_names_of_type:sc(gnot('object:map')) self.contour_sc = lambda sc=self.Shortcut,gnot=self.get_names_of_type:sc(gnot('object:mesh')+gnot('object:surface')) self.group_sc = lambda sc=self.Shortcut,gnot=self.get_names_of_type:sc(gnot('object:group')) self.fb_action_sc = pymol.feedingback.fb_action_sc self.fb_module_sc = pymol.feedingback.fb_module_sc self.fb_mask_sc = pymol.feedingback.fb_mask_sc self.auto_arg = pymol.completing.get_auto_arg_list(self) self.color_sc = None # keyboard configuration from pymol import keyboard self.key_mappings = keyboard.get_default_keys(self)
def __init__(self, _pymol, _COb): global cmd cmd = self # store parent self._pymol = _pymol # store C object for easy access self._COb = _COb # private data self.color_sc = None self.reaper = None # CONSTANTS (pymol/constants.py) self.fb_debug = global_cmd.fb_debug # this cannot be right... # deferred initiailization global_cmd._deferred_init_pymol_internals(_pymol) # PRIVATE FUNCTIONS (requiring '_self' as a keyword argument) # locking.py self.reaper = None if 1: # use own locks (for performance) self.lock_api = _pymol.lock_api self.lock_api_c = _pymol.lock_api_c self.lock_api_data = _pymol.lock_api_data self.lock_api_glut = _pymol.lock_api_glut self.lock_api_status = _pymol.lock_api_status else: # use global locks (for debugging) self.lock_api = global_cmd._pymol.lock_api self.lock_api_c = global_cmd._pymol.lock_api_c self.lock_api_data = global_cmd._pymol.lock_api_data self.lock_api_glut = global_cmd._pymol.lock_api_glut self.lock_api_status = global_cmd._pymol.lock_api_status self.lock_api_allow_flush = 1 # now we create the command langauge from pymol import keywords self.keyword = keywords.get_command_keywords() self.kw_list = self.keyword.keys() keywords.fix_list(self.kw_list) self.kwhash = self.Shortcut(self.kw_list) keywords.fix_dict(self.keyword) self.help_only = keywords.get_help_only_keywords() self.help_sc = self.Shortcut(self.keyword.keys()+self.help_only.keys()) self.selection_sc = lambda sc=self.Shortcut,gn=self.get_names:sc(gn('public')+['all']) self.object_sc = lambda sc=self.Shortcut,gn=self.get_names:sc(gn('objects')) self.map_sc = lambda sc=self.Shortcut,gnot=self.get_names_of_type:sc(gnot('object:map')) self.contour_sc = lambda sc=self.Shortcut,gnot=self.get_names_of_type:sc(gnot('object:mesh')+gnot('object:surface')) self.group_sc = lambda sc=self.Shortcut,gnot=self.get_names_of_type:sc(gnot('object:group')) self.fb_action_sc = pymol.feedingback.fb_action_sc self.fb_module_sc = pymol.feedingback.fb_module_sc self.fb_mask_sc = pymol.feedingback.fb_mask_sc self.auto_arg = pymol.completing.get_auto_arg_list(self) self.color_sc = None # keyboard configuration from pymol import keyboard self.special = keyboard.get_special(self) self.shft_special = keyboard.get_shft_special(self) self.alt_special = keyboard.get_alt_special(self) self.ctrl_special = keyboard.get_ctrl_special(self) self.ctsh_special = keyboard.get_ctsh_special(self) self.ctrl = keyboard.get_ctrl(self) self.alt = keyboard.get_alt(self)
def __init__(self, _pymol, _COb): global cmd cmd = self # store parent self._pymol = _pymol # store C object for easy access self._COb = _COb # private data self.color_sc = None self.reaper = None # CONSTANTS (pymol/constants.py) self.fb_debug = global_cmd.fb_debug # this cannot be right... # deferred initiailization global_cmd._deferred_init_pymol_internals(_pymol) # PRIVATE FUNCTIONS (requiring '_self' as a keyword argument) # locking.py self.reaper = None if 1: # use own locks (for performance) self.lock_api = _pymol.lock_api self.lock_api_c = _pymol.lock_api_c self.lock_api_data = _pymol.lock_api_data self.lock_api_glut = _pymol.lock_api_glut self.lock_api_status = _pymol.lock_api_status else: # use global locks (for debugging) self.lock_api = global_cmd._pymol.lock_api self.lock_api_c = global_cmd._pymol.lock_api_c self.lock_api_data = global_cmd._pymol.lock_api_data self.lock_api_glut = global_cmd._pymol.lock_api_glut self.lock_api_status = global_cmd._pymol.lock_api_status self.lock_api_allow_flush = 1 self.lockcm = global_cmd.LockCM(self) # now we create the command langauge from pymol import keywords self.keyword = keywords.get_command_keywords() self.kw_list = self.keyword.keys() keywords.fix_list(self.kw_list) self.kwhash = self.Shortcut(self.kw_list) keywords.fix_dict(self.keyword) self.help_only = keywords.get_help_only_keywords() self.help_sc = self.Shortcut(self.keyword.keys() + self.help_only.keys()) self.selection_sc = lambda sc=self.Shortcut, gn=self.get_names: sc( gn('public') + ['all']) self.object_sc = lambda sc=self.Shortcut, gn=self.get_names: sc( gn('objects')) self.map_sc = lambda sc=self.Shortcut, gnot=self.get_names_of_type: sc( gnot('object:map')) self.contour_sc = lambda sc=self.Shortcut, gnot=self.get_names_of_type: sc( gnot('object:mesh') + gnot('object:surface')) self.group_sc = lambda sc=self.Shortcut, gnot=self.get_names_of_type: sc( gnot('object:group')) self.fb_action_sc = pymol.feedingback.fb_action_sc self.fb_module_sc = pymol.feedingback.fb_module_sc self.fb_mask_sc = pymol.feedingback.fb_mask_sc self.auto_arg = pymol.completing.get_auto_arg_list(self) self.color_sc = None # keyboard configuration from pymol import keyboard self.key_mappings = keyboard.get_default_keys(self)
def __init__(self, _pymol, _COb): # store parent self._pymol = _pymol # store C object for easy access self._COb = _COb # private data self.color_sc = None self.reaper = None # CONSTANTS (pymol/constants.py) self.DEFAULT_ERROR = global_cmd.DEFAULT_ERROR self.DEFAULT_SUCCESS = global_cmd.DEFAULT_SUCCESS self.QuietException = global_cmd.QuietException self.Shortcut = global_cmd.Shortcut self._load2str = global_cmd._load2str self.boolean_dict = global_cmd.boolean_dict self.boolean_sc = global_cmd.boolean_sc self.fb_action = global_cmd.fb_action self.fb_mask = global_cmd.fb_mask self.fb_module = global_cmd.fb_module self.fb_debug = global_cmd.fb_debug # this cannot be right... self.file_ext_re = global_cmd.file_ext_re self.gz_ext_re = global_cmd.gz_ext_re self.loadable = global_cmd.loadable self.nt_hidden_path_re = global_cmd.nt_hidden_path_re self.palette_dict = global_cmd.palette_dict self.palette_sc = global_cmd.palette_sc self.parsing = global_cmd.parsing self.quote_alpha_list_re = global_cmd.quote_alpha_list_re self.repres = global_cmd.repres self.repres_sc = global_cmd.repres_sc self.safe_alpha_list_eval = global_cmd.safe_alpha_list_eval self.safe_list_eval = global_cmd.safe_list_eval self.safe_oname_re = global_cmd.safe_oname_re self.sanitize_alpha_list_re = global_cmd.sanitize_alpha_list_re self.sanitize_list_re = global_cmd.sanitize_list_re self.space_sc = global_cmd.space_sc self.stereo_dict = global_cmd.stereo_dict self.stereo_sc = global_cmd.stereo_sc self.toggle_dict = global_cmd.toggle_dict self.toggle_sc = global_cmd.toggle_sc self.window_dict = global_cmd.window_dict self.window_sc = global_cmd.window_sc # GLOBAL FUNCTIONS self.exp_path = global_cmd.exp_path # deferred initiailization global_cmd._deferred_init_pymol_internals(_pymol) # PRIVATE FUNCTIONS (requiring '_self' as a keyword argument) # locking.py self.reaper = None if 1: # use own locks (for performance) self.lock_api = _pymol.lock_api self.lock_api_c = _pymol.lock_api_c self.lock_api_data = _pymol.lock_api_data self.lock_api_glut = _pymol.lock_api_glut self.lock_api_status = _pymol.lock_api_status else: # use global locks (for debugging) self.lock_api = global_cmd._pymol.lock_api self.lock_api_c = global_cmd._pymol.lock_api_c self.lock_api_data = global_cmd._pymol.lock_api_data self.lock_api_glut = global_cmd._pymol.lock_api_glut self.lock_api_status = global_cmd._pymol.lock_api_status self.lock_api_allow_flush = 1 self.lock_c = global_cmd.lock_c self.unlock_c = global_cmd.unlock_c self.lock_data = global_cmd.lock_data self.unlock_data = global_cmd.unlock_data self.lock_status_attempt = global_cmd.lock_status_attempt self.lock_status = global_cmd.lock_status self.unlock_status = global_cmd.unlock_status self.lock_glut = global_cmd.lock_glut self.unlock_glut = global_cmd.unlock_glut self.lock_without_glut = global_cmd.lock_without_glut self.lock = global_cmd.lock self.lock_attempt = global_cmd.lock_attempt self.unlock = global_cmd.unlock self.is_glut_thread = global_cmd.is_glut_thread self.setup_global_locks = global_cmd.setup_global_locks self.interrupt = global_cmd.interrupt self.block_flush = global_cmd.block_flush self.unblock_flush = global_cmd.unblock_flush # pymol/checking.py self._raising = global_cmd._raising self.is_dict = global_cmd.is_dict self.is_error = global_cmd.is_error self.is_list = global_cmd.is_list self.is_ok = global_cmd.is_ok self.is_sequence = global_cmd.is_sequence self.is_string = global_cmd.is_string self.is_tuple = global_cmd.is_tuple # from pymol/feedingback.py self._feedback = global_cmd._feedback # from pymol/internal.py self._adjust_coord = global_cmd._adjust_coord self._coordset_update_spawn = global_cmd._coordset_update_spawn self._coordset_update_thread = global_cmd._coordset_update_thread self._copy_image = global_cmd._copy_image self._do = global_cmd._do self._dump_floats = global_cmd._dump_floats self._dump_ufloats = global_cmd._dump_ufloats self._fake_drag = global_cmd._fake_drag self._get_color_sc = global_cmd._get_color_sc self._get_feedback = global_cmd._get_feedback self._interpret_color = global_cmd._interpret_color self._interpret_color = global_cmd._interpret_color self._invalidate_color_sc = global_cmd._invalidate_color_sc self._invalidate_color_sc = global_cmd._invalidate_color_sc self._load = global_cmd._load self._mpng = global_cmd._mpng self._object_update_spawn = global_cmd._object_update_spawn self._object_update_thread = global_cmd._object_update_thread self._png = global_cmd._png self._quit = global_cmd._quit self._ray_anti_spawn = global_cmd._ray_anti_spawn self._ray_hash_spawn = global_cmd._ray_hash_spawn self._ray_spawn = global_cmd._ray_spawn self._refresh = global_cmd._refresh self._sgi_stereo = global_cmd._sgi_stereo self._validate_color_sc = global_cmd._validate_color_sc self._cache_set = global_cmd._cache_set self._cache_get = global_cmd._cache_get self._cache_clear = global_cmd._cache_clear self._cache_mark = global_cmd._cache_mark self._cache_purge = global_cmd._cache_purge # now we create the command langauge from pymol import keywords self.keyword = keywords.get_command_keywords() self.kw_list = self.keyword.keys() keywords.fix_list(self.kw_list) self.kwhash = self.Shortcut(self.kw_list) keywords.fix_dict(self.keyword) self.controlling = pymol.controlling self.completing = pymol.completing self.controlling = pymol.controlling self.editing = pymol.editing self.exporting = pymol.exporting self.moving = pymol.moving self.creating = pymol.creating self.viewing = pymol.viewing self.setting = pymol.setting self.commanding = pymol.commanding self.help_only = keywords.get_help_only_keywords() self.help_sc = self.Shortcut(self.keyword.keys() + self.help_only.keys()) self.selection_sc = lambda sc=self.Shortcut, gn=self.get_names: sc( gn('public') + ['all']) self.object_sc = lambda sc=self.Shortcut, gn=self.get_names: sc( gn('objects')) self.map_sc = lambda sc=self.Shortcut, gnot=self.get_names_of_type: sc( gnot('object:map')) self.contour_sc = lambda sc=self.Shortcut, gnot=self.get_names_of_type: sc( gnot('object:mesh') + gnot('object:surface')) self.fb_action_sc = pymol.feedingback.fb_action_sc self.fb_module_sc = pymol.feedingback.fb_module_sc self.fb_mask_sc = pymol.feedingback.fb_mask_sc self.auto_arg = pymol.completing.get_auto_arg_list(self) self.color_sc = None # keyboard configuration from pymol import keyboard self.special = keyboard.get_special(self) self.shft_special = keyboard.get_shft_special(self) self.alt_special = keyboard.get_alt_special(self) self.ctrl_special = keyboard.get_ctrl_special(self) self.ctsh_special = keyboard.get_ctsh_special(self) self.ctrl = keyboard.get_ctrl(self) self.alt = keyboard.get_alt(self)