"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "modules/pymol2/cmd2.py" between
pymol-v1.8.6.0.tar.bz2 and pymol-v2.1.0.tar.bz2

About: PyMOL is a Python-enhanced molecular graphics tool. It excels at 3D visualization of proteins, small molecules, density, surfaces, and trajectories. It also includes molecular editing, ray tracing, and movies. Open Source version.

cmd2.py  (pymol-v1.8.6.0.tar.bz2):cmd2.py  (pymol-v2.1.0.tar.bz2)
from pymol import cmd as global_cmd from pymol import cmd as global_cmd
import pymol import pymol
import inspect import inspect
import itertools
import weakref
#most recently created Cmd (for now) #most recently created Cmd (for now)
cmd = None cmd = None
class Cmd: class Cmd:
''' '''
Proxy for the pymol.cmd module for multiple instances support. Proxy for the pymol.cmd module for multiple instances support.
''' '''
def __init__(self, _pymol, _COb): def __init__(self, _pymol, _COb):
global cmd global cmd
cmd = self cmd = weakref.proxy(self)
self._weakref = weakref.ref(self)
self._weakrefproxy = weakref.proxy(self)
# store parent # store parent
self._pymol = _pymol self._pymol = weakref.proxy(_pymol)
# store C object for easy access # store C object for easy access
self._COb = _COb self._COb = _COb
# private data # private data
self.color_sc = None self.color_sc = None
self.reaper = None self.reaper = None
# CONSTANTS (pymol/constants.py)
self.fb_debug = global_cmd.fb_debug # this cannot be right...
# deferred initiailization # deferred initiailization
global_cmd._deferred_init_pymol_internals(_pymol) global_cmd._deferred_init_pymol_internals(_pymol)
# PRIVATE FUNCTIONS (requiring '_self' as a keyword argument) # PRIVATE FUNCTIONS (requiring '_self' as a keyword argument)
# locking.py # locking.py
self.reaper = None self.reaper = None
skipping to change at line 66 skipping to change at line 67
self.lock_api_status = global_cmd._pymol.lock_api_status self.lock_api_status = global_cmd._pymol.lock_api_status
self.lock_api_allow_flush = 1 self.lock_api_allow_flush = 1
self.lockcm = global_cmd.LockCM(self) self.lockcm = global_cmd.LockCM(self)
# now we create the command langauge # now we create the command langauge
from pymol import keywords from pymol import keywords
self.keyword = keywords.get_command_keywords() self.keyword = keywords.get_command_keywords()
self.kw_list = self.keyword.keys() self.kw_list = list(self.keyword)
keywords.fix_list(self.kw_list) keywords.fix_list(self.kw_list)
self.kwhash = self.Shortcut(self.kw_list) self.kwhash = self.Shortcut(self.kw_list)
keywords.fix_dict(self.keyword) keywords.fix_dict(self.keyword)
self.help_only = keywords.get_help_only_keywords() self.help_only = keywords.get_help_only_keywords()
self.help_sc = self.Shortcut(self.keyword.keys()+self.help_only.keys()) 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('pub lic')+['all']) self.selection_sc = lambda sc=self.Shortcut,gn=self.get_names:sc(gn('pub lic')+['all'])
self.object_sc = lambda sc=self.Shortcut,gn=self.get_names:sc(gn('object s')) self.object_sc = lambda sc=self.Shortcut,gn=self.get_names:sc(gn('object s'))
self.map_sc = lambda sc=self.Shortcut,gnot=self.get_names_of_type:sc(gno t('object:map')) self.map_sc = lambda sc=self.Shortcut,gnot=self.get_names_of_type:sc(gno t('object:map'))
self.contour_sc = lambda sc=self.Shortcut,gnot=self.get_names_of_type:s c(gnot('object:mesh')+gnot('object:surface')) self.contour_sc = lambda sc=self.Shortcut,gnot=self.get_names_of_type:s c(gnot('object:mesh')+gnot('object:surface'))
self.group_sc = lambda sc=self.Shortcut,gnot=self.get_names_of_type:sc(g not('object:group')) self.group_sc = lambda sc=self.Shortcut,gnot=self.get_names_of_type:sc(g not('object:group'))
self.fb_action_sc = pymol.feedingback.fb_action_sc self.fb_action_sc = pymol.feedingback.fb_action_sc
self.fb_module_sc = pymol.feedingback.fb_module_sc self.fb_module_sc = pymol.feedingback.fb_module_sc
self.fb_mask_sc = pymol.feedingback.fb_mask_sc self.fb_mask_sc = pymol.feedingback.fb_mask_sc
skipping to change at line 103 skipping to change at line 105
# PUBLIC API METHODS which expect "self" as the first argument # PUBLIC API METHODS which expect "self" as the first argument
def __getattr__(self, key): def __getattr__(self, key):
v = getattr(global_cmd, key) v = getattr(global_cmd, key)
try: try:
i = inspect.getargspec(v).args.index('_self') i = inspect.getargspec(v).args.index('_self')
except: except:
setattr(self, key, v) setattr(self, key, v)
return v return v
# don't bind a circular reference into the wrapper
# namespace, use a weak reference instead
cmdref = self._weakref
def wrapper(*a, **k): def wrapper(*a, **k):
if len(a) <= i: if len(a) <= i:
k['_self'] = self k['_self'] = cmdref()
return v(*a, **k) return v(*a, **k)
wrapper.__name__ = key wrapper.__name__ = key
setattr(self, key, wrapper) setattr(self, key, wrapper)
return wrapper return wrapper
 End of changes. 8 change blocks. 
9 lines changed or deleted 14 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)