Skip to content

Commit

Permalink
fixing imports for class Shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
ye11owSub committed Aug 17, 2024
1 parent f1494f1 commit cf243e2
Show file tree
Hide file tree
Showing 20 changed files with 50 additions and 34 deletions.
4 changes: 3 additions & 1 deletion modules/pymol/commanding.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#-*
#Z* -------------------------------------------------------------------

from pymol.shortcut import Shortcut

if True:

import sys
Expand Down Expand Up @@ -39,7 +41,7 @@
cmd = sys.modules["pymol.cmd"]
import pymol

from .cmd import _cmd, Shortcut, QuietException, \
from .cmd import _cmd, QuietException, \
fb_module, fb_mask, is_list, \
DEFAULT_ERROR, DEFAULT_SUCCESS, is_ok, is_error, is_string

Expand Down
30 changes: 16 additions & 14 deletions modules/pymol/completing.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from pymol.shortcut import Shortcut

cmd = __import__("sys").modules["pymol.cmd"]

class ExprShortcut(cmd.Shortcut):
class ExprShortcut(Shortcut):
'''
Expression shortcut for iterate/alter/label with "s." prefix
setting autocompletion.
'''
def interpret(self, kee, mode=0):
if not kee.startswith('s.'):
return cmd.Shortcut.interpret(self, kee, mode)
v = cmd.setting.setting_sc.interpret(kee[2:])
def interpret(self, keyword, mode=False):
if not keyword.startswith('s.'):
return super().interpret(keyword, mode)
v = cmd.setting.setting_sc.interpret(keyword[2:])
if isinstance(v, str):
return 's.' + v
if isinstance(v, list):
Expand All @@ -32,17 +34,17 @@ def interpret(self, kee, mode=0):
def fragments_sc():
import os
import chempy
return cmd.Shortcut([
return Shortcut([
f[:-4] for f in os.listdir(chempy.path + 'fragments')
if f.endswith('.pkl')
])


def vol_ramp_sc():
from . import colorramping
return cmd.Shortcut(colorramping.namedramps)
return Shortcut(colorramping.namedramps)

names_sc = lambda: cmd.Shortcut(cmd.get_names('public'))
names_sc = lambda: Shortcut(cmd.get_names('public'))

aa_nam_e = [ names_sc , 'name' , '' ]
aa_nam_s = [ names_sc , 'name' , ' ' ]
Expand All @@ -58,24 +60,24 @@ def vol_ramp_sc():
aa_rep_c = [ cmd.repres_sc , 'representation' , ', ' ]
aa_rem_c = [ cmd.repmasks_sc , 'representation' , ', ' ]
aa_v_r_c = [ vol_ramp_sc , 'volume ramp' , ', ' ]
aa_ali_e = [ cmd.Shortcut(['align', 'super', 'cealign']), 'alignment method', '']
aa_ali_e = [ Shortcut(['align', 'super', 'cealign']), 'alignment method', '']

def wizard_sc():
import os, pymol.wizard
names_glob = [name[:-3] for p in pymol.wizard.__path__
for name in os.listdir(p) if name.endswith('.py')]
return cmd.Shortcut(names_glob)
return Shortcut(names_glob)

def get_auto_arg_list(self_cmd=cmd):
self_cmd = self_cmd._weakrefproxy

aa_vol_c = [ lambda:
cmd.Shortcut(self_cmd.get_names_of_type('object:volume')),
Shortcut(self_cmd.get_names_of_type('object:volume')),
'volume', '' ]
aa_ramp_c = [ lambda:
cmd.Shortcut(self_cmd.get_names_of_type('object:ramp')),
Shortcut(self_cmd.get_names_of_type('object:ramp')),
'ramp', '' ]
aa_scene_e = [lambda: cmd.Shortcut(cmd.get_scene_list()), 'scene', '']
aa_scene_e = [lambda: Shortcut(cmd.get_scene_list()), 'scene', '']

return [
# 1st
Expand Down Expand Up @@ -168,7 +170,7 @@ def get_auto_arg_list(self_cmd=cmd):
'sculpt_iterate' : aa_obj_c,
'set' : aa_set_c,
'set_bond' : aa_set_c,
'set_key' : [ lambda: cmd.Shortcut(cmd.key_mappings), 'key' , ', ' ],
'set_key' : [ lambda: Shortcut(cmd.key_mappings), 'key' , ', ' ],
'set_name' : aa_nam_c,
'set_title' : aa_obj_c,
'show' : aa_rem_c,
Expand Down
2 changes: 1 addition & 1 deletion modules/pymol/constants.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

# constant objects

from pymol.shortcut import Shortcut
from .parsing import QuietException
from .shortcut import Shortcut
from .constants_palette import palette_dict
import re

Expand Down
4 changes: 2 additions & 2 deletions modules/pymol/controlling.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
#-*
#Z* -------------------------------------------------------------------

from pymol.shortcut import Shortcut

if True:
try:
from . import selector, internal
from .shortcut import Shortcut
cmd = __import__("sys").modules["pymol.cmd"]
from .cmd import _cmd, QuietException, is_string, \
boolean_dict, boolean_sc, \
DEFAULT_ERROR, DEFAULT_SUCCESS, is_ok, is_error, \
location_code, location_sc
import pymol
except:
from shortcut import Shortcut
cmd = None


Expand Down
3 changes: 2 additions & 1 deletion modules/pymol/creating.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#-*
#Z* -------------------------------------------------------------------

from pymol.shortcut import Shortcut
from .constants import CURRENT_STATE, ALL_STATES

if True:
Expand All @@ -23,7 +24,7 @@
import re
import gzip
import os
from .cmd import _cmd, Shortcut, is_list, is_string, \
from .cmd import _cmd, is_list, is_string, \
safe_list_eval, safe_alpha_list_eval, \
DEFAULT_ERROR, DEFAULT_SUCCESS, is_ok, is_error, \
is_tuple
Expand Down
3 changes: 2 additions & 1 deletion modules/pymol/editing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#Z* -------------------------------------------------------------------

import pymol
from pymol.shortcut import Shortcut
from .constants import CURRENT_STATE, ALL_STATES


Expand Down Expand Up @@ -67,7 +68,7 @@ def _iterate_prepare_args(expression, space, _self):
import math
from . import selector
cmd = __import__("sys").modules["pymol.cmd"]
from .cmd import _cmd,lock,unlock,Shortcut,is_string, \
from .cmd import _cmd,lock,unlock,is_string, \
boolean_sc,boolean_dict,safe_list_eval, is_sequence, \
DEFAULT_ERROR, DEFAULT_SUCCESS, _raising, is_ok, is_error
from chempy import cpv
Expand Down
2 changes: 1 addition & 1 deletion modules/pymol/experimenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
if True:

from . import selector
from .cmd import _cmd,lock,unlock,Shortcut,QuietException, \
from .cmd import _cmd,lock,unlock,QuietException, \
DEFAULT_ERROR, DEFAULT_SUCCESS, _raising, is_ok, is_error
cmd = __import__("sys").modules["pymol.cmd"]
import threading
Expand Down
3 changes: 2 additions & 1 deletion modules/pymol/exporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#-*
#Z* -------------------------------------------------------------------

from pymol.shortcut import Shortcut
from . import colorprinting

if True:
Expand All @@ -24,7 +25,7 @@

import pymol
cmd = sys.modules["pymol.cmd"]
from .cmd import _cmd,Shortcut,QuietException
from .cmd import _cmd,QuietException
from chempy import io
from chempy.pkl import cPickle
from .cmd import _feedback,fb_module,fb_mask, \
Expand Down
2 changes: 1 addition & 1 deletion modules/pymol/externing.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import traceback

from glob import glob
from .cmd import _cmd,lock,unlock,Shortcut,QuietException, \
from .cmd import _cmd,lock,unlock,QuietException, \
_feedback,fb_module,fb_mask, exp_path, \
DEFAULT_ERROR, DEFAULT_SUCCESS, _raising, is_ok, is_error

Expand Down
3 changes: 2 additions & 1 deletion modules/pymol/feedingback.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
from pymol.shortcut import Shortcut
cmd = __import__("sys").modules["pymol.cmd"]
from .cmd import Shortcut, is_string, QuietException
from .cmd import is_string, QuietException
from .cmd import fb_module, fb_mask, fb_action,_raising
import copy

Expand Down
2 changes: 1 addition & 1 deletion modules/pymol/fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import os
import pymol

from .cmd import _cmd,lock,unlock,Shortcut, \
from .cmd import _cmd,lock,unlock, \
DEFAULT_ERROR, DEFAULT_SUCCESS, _raising, is_ok, is_error


Expand Down
3 changes: 2 additions & 1 deletion modules/pymol/internal.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
cmd = sys.modules["pymol.cmd"]
from pymol.shortcut import Shortcut
from pymol import _cmd
import threading
import traceback
Expand All @@ -14,7 +15,7 @@

import chempy.io

from .cmd import DEFAULT_ERROR, DEFAULT_SUCCESS, loadable, _load2str, Shortcut, \
from .cmd import DEFAULT_ERROR, DEFAULT_SUCCESS, loadable, _load2str, \
is_string, is_ok

# cache management:
Expand Down
3 changes: 2 additions & 1 deletion modules/pymol/movie.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import threading
import time
from . import colorprinting
from pymol.shortcut import Shortcut

def get_movie_fps(_self):
r = _self.get_setting_float('movie_fps')
Expand Down Expand Up @@ -817,7 +818,7 @@ def _encode(filename,first,last,preserve,
'ray' : 2,
}

produce_mode_sc = cmd.Shortcut(produce_mode_dict.keys())
produce_mode_sc = Shortcut(produce_mode_dict.keys())


def find_exe(exe):
Expand Down
3 changes: 2 additions & 1 deletion modules/pymol/moving.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#-*
#-*
#Z* -------------------------------------------------------------------
from pymol.shortcut import Shortcut

if True:

Expand All @@ -21,7 +22,7 @@
import pymol
import re
cmd = sys.modules["pymol.cmd"]
from .cmd import _cmd,Shortcut, \
from .cmd import _cmd, \
toggle_dict,toggle_sc, \
DEFAULT_ERROR, DEFAULT_SUCCESS, _raising, is_ok, is_error

Expand Down
3 changes: 2 additions & 1 deletion modules/pymol/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import pymol
from pymol import cmd
from pymol import colorprinting
from pymol.shortcut import Shortcut
from .legacysupport import *

# variables
Expand Down Expand Up @@ -434,6 +435,6 @@ def initialize(pmgapp=-1):
cmd.extend('plugin_pref_save', pref_save)

# autocompletion
cmd.auto_arg[0]['plugin_load'] = [ lambda: cmd.Shortcut(plugins), 'plugin', '' ]
cmd.auto_arg[0]['plugin_load'] = [ lambda: Shortcut(plugins), 'plugin', '' ]

# vi:expandtab:smarttab:sw=4
2 changes: 1 addition & 1 deletion modules/pymol/querying.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from . import selector
import pymol
cmd = __import__("sys").modules["pymol.cmd"]
from .cmd import _cmd,lock,unlock,Shortcut, \
from .cmd import _cmd,lock,unlock, \
_feedback,fb_module,fb_mask,is_list, \
DEFAULT_ERROR, DEFAULT_SUCCESS, _raising, is_ok, is_error

Expand Down
3 changes: 2 additions & 1 deletion modules/pymol/selecting.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
#-*
#-*
#Z* -------------------------------------------------------------------
from pymol.shortcut import Shortcut

if True:

from . import selector

cmd = __import__("sys").modules["pymol.cmd"]

from .cmd import _cmd,Shortcut, \
from .cmd import _cmd, \
DEFAULT_ERROR, DEFAULT_SUCCESS, _raising, is_ok, is_error

import pymol
Expand Down
4 changes: 3 additions & 1 deletion modules/pymol/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#Z* -------------------------------------------------------------------

# must match layer1/Setting.h
from pymol.shortcut import Shortcut


cSetting_tuple = -1
cSetting_blank = 0
cSetting_boolean = 1
Expand All @@ -26,7 +29,6 @@

import traceback
from . import selector
from .shortcut import Shortcut
cmd = __import__("sys").modules["pymol.cmd"]
from .cmd import _cmd,lock,lock_attempt,unlock,QuietException, \
is_string, \
Expand Down
3 changes: 2 additions & 1 deletion modules/pymol/viewing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#-*
#Z* -------------------------------------------------------------------

from pymol.shortcut import Shortcut
from . import colorprinting

if True:
Expand All @@ -25,7 +26,7 @@
import re
cmd = sys.modules["pymol.cmd"]

from .cmd import _cmd, Shortcut, \
from .cmd import _cmd, \
_feedback,fb_module,fb_mask, \
repres,repres_sc, is_string, is_list, \
repmasks,repmasks_sc, \
Expand Down
2 changes: 1 addition & 1 deletion modules/pymol/wizarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import pymol
import sys
cmd = __import__("sys").modules["pymol.cmd"]
from .cmd import _cmd,lock,unlock,Shortcut,QuietException,_raising, \
from .cmd import _cmd,lock,unlock,QuietException,_raising, \
_feedback,fb_module,fb_mask, \
DEFAULT_ERROR, DEFAULT_SUCCESS, _raising, is_ok, is_error

Expand Down

0 comments on commit cf243e2

Please sign in to comment.