本文整理汇总了Python中utilities.debug.print_compact_stack函数的典型用法代码示例。如果您正苦于以下问题:Python print_compact_stack函数的具体用法?Python print_compact_stack怎么用?Python print_compact_stack使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_compact_stack函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_unit_length
def get_unit_length(phi, psi):
"""
Calculate a length of single amino acid in particular
secondary conformation.
"""
# All unit length values obtained via measurements by me.
# Fixes bug 2959. --Mark 2008-12-23
if phi == -57.0 and psi == -47.0:
unit_length = 1.5 # Alpha helix
elif phi == -135.0 and psi == 135.0:
unit_length = 3.4 # Beta strand
elif phi == -55.0 and psi == -70.0:
unit_length = 1.05 # Pi helix
elif phi == -49.0 and psi == -26.0:
unit_length = 1.95 # 3_10 helix
elif phi == -75.0 and psi == 150.0:
unit_length = 3.14 # Polyproline-II helix
elif phi == -180.0 and psi == 180.0:
unit_length = 3.6 # Fully extended
else:
# User chose "Custom" conformation option in the Insert Peptide PM
# which lets the user set any phi-psi angle values.
# We need a formula to estimate the proper unit_length given the
# conformational angles phi and psi. It would also be a good idea
# to check these values to confirm they are an allowed combination.
# For more info, do a google search for "Ramachandran plot".
# For now, I'm setting the unit length to 1.5. --Mark 2008-12-23
unit_length = 1.5
msg = "\nUser selected custom conformational angles: "\
"phi=%.2f, psi=%.2f.\nSetting unit_length=%.2f\n" % \
(phi, psi, unit_length)
print_compact_stack(msg)
return unit_length
示例2: careful_widget_setter
def careful_widget_setter(self, value):
# Note: for some time we used self.widget_setter rather than this method,
# by mistake, and it apparently worked fine. We'll still use this method
# as a precaution; also it might be truly needed if the widget quantizes
# the value, unless the widget refrains from sending signals when
# programmatically set. [bruce 070815]
if self.debug:
print "\n_changes__debug_print: %r setting %r to %r using %r" % \
( self, self.widget, value, self.widget_setter )
self.disconnect() # avoid possible recursion
try:
self.widget_setter(value)
except:
print_compact_traceback("bug: ignoring exception setting value of %r to %r: " % (self, value))
print_compact_stack(" fyi: prior exception came from: ")
self.destroy() #bruce 080930
# this seems to be safe, but debug output implies it fails to stop formula
# from continuing to call setter! but that seems unlikely... nevermind for now.
# Review: do we want subsequent use of self
# to be silently ok, smaller message, or error? If this destroy worked
# then I think it should be silently ok, but might not be now,
# depending on how refs to self continue to be used.
pass
else:
self.connect()
### WARNING: .connect is slow, since it runs our Python code to set up an undo wrapper
# around the slot! We should revise this to tell Qt to block the signals instead.
# [We can use: bool QObject::blockSignals ( bool block ) ==> returns prior value of signalsBlocked,
# now used in a helper function setValue_with_signals_blocked]
# This will matter for performance when this is used for state which changes during a drag.
# Note: avoiding the slot call is needed not only for recursion, but to avoid the
# Undo checkpoint in the wrapper.
# [bruce comments 071015; see also bug 2564 in other code]
return
示例3: getStrands
def getStrands(self):
"""
Returns a list of strands inside a DnaGroup object
@return: A list containing all the strand objects
within self.
@rtype: list
@see: B{BuildDna_PropertyManager.updateStrandListWidget()}
@see: B{BuildDna_PropertyManager._currentSelectionParams}
"""
#TO BE REVISED. As of 2008-01-17, it uses isinstance check for
#Chunk and some additional things to find out a list of strands inside
# a DnaGroup -- Ninad 2008-01-17
if self.assy is None:
#This is to avoid possible bugs if group gets deleted. But print
#traceback so that we know about this bug. This could happen due to
#insufficient command sequencer stack. Temporary fix for bug 2699
print_compact_stack("bug: self.assy is None for DnaGroup %s."%self)
return ()
strandList = []
def filterStrands(node):
if isinstance(node, self.assy.DnaStrand) and not node.isEmpty():
strandList.append(node)
elif isinstance(node, self.assy.Chunk) and node.isStrandChunk():
if node.parent_node_of_class(self.assy.DnaStrand) is None:
strandList.append(node)
self.apply2all(filterStrands)
return strandList
示例4: getAxisChunks
def getAxisChunks(self):
"""
Returns a list of Axis chunks inside a DnaGroup object
@return: A list containing all the axis chunks
within self.
@rtype: list
"""
if self.assy is None:
#This is to avoid possible bugs if group gets deleted. But print
#traceback so that we know about this bug. This could happen due to
#insufficient command sequencer stack. Temporary fix for bug 2699
print_compact_stack("bug: self.assy is None for DnaGroup %s."%self)
return ()
#TO BE REVISED. It uses isinstance check for
#Chunk and some additional things to find out a list of strands inside
# a DnaGroup -- Ninad 2008-02-02
axisChunkList = []
def filterAxisChunks(node):
if isinstance(node, self.assy.Chunk) and node.isAxisChunk():
axisChunkList.append(node)
self.apply2all(filterAxisChunks)
return axisChunkList
示例5: get_image_path
def get_image_path(name, print_errors = True):
"""
Return the full path given an image/icon path name.
@param name: The image path name provided by the user. The path should start
with 'ui/' directory inside the src directory.
@type name: str
@param print_errors: whether to report errors for missing icon files
when atom_debug is set. True by default.
@type print_errors: boolean
@return: full path of the image.
@rtype: str
"""
root, ext = os.path.splitext(name)
if not ext:
if name: # 'name' can be an empty string. See docstring for details.
msg = "Warning: No '.png' extension passed to get_image_path for [%s]. " \
"\nPlease add the .png suffix in the source code to remove this warning.\n" % name
print_compact_stack(msg)
name = name + '.png'
iconPath = os.path.join(image_directory(), name)
iconPath = os.path.normpath(iconPath)
if not os.path.exists(iconPath):
if debug_flags.atom_debug and print_errors:
print "icon path %s doesn't exist." % (iconPath,)
return iconPath
示例6: _get_mode
def _get_mode(self):
"""
Old code is trying to get self.mode,
which it might want for either the Command API (self.currentCommand)
or GraphicsMode API (self.graphicsMode). We don't know which it wants.
(TODO, if worthwhile: deduce which, print a map of code line vs
which one of these to change it to.)
This can only be supported if the currentCommand is also old, so that
it handles both APIs.
Print a warning if not (or assert 0?), and return the currentCommand
in either case (but don't wrap it with an API enforcer).
"""
# Note: when we think there are not many uses of this left,
# we'll make every use print_compact_stack to aid in finding the rest
# and replacing them with one or the other of currentCommand and
# graphicsMode. Or we might print a once-per-line-number message when
# it's called... ### TODO
#
# hmm, this is true now! [bruce 071011]
print_compact_stack("fyi: this old code still accesses glpane.mode " \
"by that deprecated name: ")
raw_currentCommand = self._raw_currentCommand
graphicsMode = self._raw_currentCommand.graphicsMode
if raw_currentCommand is not graphicsMode:
print "old code warning: %r is not %r and we don't know " \
"which one %r.mode should return" % \
(raw_currentCommand, graphicsMode, self)
# TODO: print_compact_stack?
return raw_currentCommand
示例7: _leftDown_preparation_for_dragging
def _leftDown_preparation_for_dragging(self, objectUnderMouse, event):
"""
Handle left down event. Preparation for rotation and/or selection
This method is called inside of self.leftDown.
@param event: The mouse left down event.
@type event: QMouseEvent instance
@see: self.leftDown
@see: self.leftDragRotation
Overrides _superclass._leftDown_preparation_for_dragging
"""
_superclass._leftDown_preparation_for_dragging(self, objectUnderMouse, event)
self.o.SaveMouse(event)
self.picking = True
self.dragdist = 0.0
# delta for constrained rotations.
self.rotDelta = 0
if self.rotateOption == "ROTATEDEFAULT":
self.o.trackball.start(self.o.MousePos[0], self.o.MousePos[1])
else:
if self.rotateOption == "ROTATEX":
ma = V(1, 0, 0) # X Axis
self.axis = "X"
elif self.rotateOption == "ROTATEY":
ma = V(0, 1, 0) # Y Axis
self.axis = "Y"
elif self.rotateOption == "ROTATEZ":
ma = V(0, 0, 1) # Z Axis
self.axis = "Z"
elif self.rotateOption == "ROT_TRANS_ALONG_AXIS":
# The method 'self._leftDown_preparation_for_dragging should
# never be reached if self.rotateOption is 'ROT_TRANS_ALONG_AXIS'
# If this code is reached, it indicates a bug. So fail gracefully
# by calling self.leftADown()
if debug_flags.atom_debug:
print_compact_stack(
"bug: _leftDown_preparation_for_dragging" " called for rotate option" "'ROT_TRANS_ALONG_AXIS'"
)
self.leftADown(objectUnderMouse, event)
return
else:
print "Move_Command: Error - unknown rotateOption value =", self.rotateOption
return
ma = norm(V(dot(ma, self.o.right), dot(ma, self.o.up)))
# When in the front view, right = 1,0,0 and up = 0,1,0, so ma will
# be computed as 0,0.This creates a special case problem when the
# user wants to constrain rotation around the Z axis because Zmat
# will be zero. So we have to test for this case (ma = 0,0) and
# fix ma to -1,0. This was needed to fix bug 537. Mark 050420
if ma[0] == 0.0 and ma[1] == 0.0:
ma = [-1.0, 0.0]
self.Zmat = A([ma, [-ma[1], ma[0]]])
self.leftDownType = "ROTATE"
return
示例8: _master_model_updater
def _master_model_updater( warn_if_needed = False ):
"""
This should be called at the end of every user event which might have
changed anything in any loaded model which defers some updates to this
function.
This can also be called at the beginning of user events, such as redraws
or saves, which want to protect themselves from event-processors which
should have called this at the end, but forgot to. Those callers should
pass warn_if_needed = True, to cause a debug-only warning to be emitted
if the call was necessary. (This function is designed
to be very fast when called more times than necessary.)
This should also be called before taking Undo checkpoints, to make sure
they correspond to legal structures, and so this function's side effects
(and the effect of assy.changed, done by this function as of 060126(?))
are treated as part of the same undoable operation as the changes that
required them to be made. As of 060127 this is done by those checkpoints
calling update_parts, which indirectly calls this function.
In practice, as of 071115, we have not yet tried to put in calls
to this function at the end of user event handlers, so we rely on the
other calls mentioned above, and none of them pass warn_if_needed.
"""
# 0. Don't run while mmp file is being read [###FIX, use one global flag]
if 1:
# KLUGE; the changedicts and updater should really be per-assy...
# this is a temporary scheme for detecting the unanticipated
# running of this in the middle of loading an mmp file, and for
# preventing errors from that,
# but it only works for the main assy -- not e.g. for a partlib
# assy. I don't yet know if this is needed. [bruce 080117]
#update 080319: just in case, I'm fixing the mmpread code
# to also use the global assy to store this.
kluge_main_assy = env.mainwindow().assy
if not kluge_main_assy.assy_valid:
global_model_changedicts.status_of_last_dna_updater_run = LAST_RUN_DIDNT_HAPPEN
msg = "deferring _master_model_updater(warn_if_needed = %r) " \
"since not %r.assy_valid" % (warn_if_needed, kluge_main_assy)
print_compact_stack(msg + ": ") # soon change to print...
return
pass
env.history.emit_all_deferred_summary_messages() #bruce 080212 (3 places)
_run_dna_updater()
env.history.emit_all_deferred_summary_messages()
_run_bond_updater( warn_if_needed = warn_if_needed)
env.history.emit_all_deferred_summary_messages()
_autodelete_empty_groups(kluge_main_assy)
env.history.emit_all_deferred_summary_messages()
return # from _master_model_updater
示例9: connect_or_disconnect_signals
def connect_or_disconnect_signals(self, isConnect):
"""
Connect or disconnect widget signals sent to their slot methods.
@param isConnect: If True the widget will send the signals to the slot
method.
@type isConnect: boolean
@see: L{BuildAtoms_Command.connect_or_disconnect_signals} where this is called
"""
if isConnect and self.isAlreadyConnected:
if debug_flags.atom_debug:
print_compact_stack("warning: attempt to connect widgets"\
"in this PM that are already connected." )
return
if not isConnect and self.isAlreadyDisconnected:
if debug_flags.atom_debug:
print_compact_stack("warning: attempt to disconnect widgets"\
"in this PM that are already disconnected.")
return
self.isAlreadyConnected = isConnect
self.isAlreadyDisconnected = not isConnect
if isConnect:
change_connect = self.w.connect
else:
change_connect = self.w.disconnect
change_connect(self.atomChooserComboBox,
SIGNAL("currentIndexChanged(int)"),
self._updateAtomChooserGroupBoxes)
change_connect(self.selectionFilterCheckBox,
SIGNAL("stateChanged(int)"),
self.set_selection_filter)
change_connect(self.showSelectedAtomInfoCheckBox,
SIGNAL("stateChanged(int)"),
self.toggle_selectedAtomPosGroupBox)
change_connect(self.xCoordOfSelectedAtom,
SIGNAL("valueChanged(double)"),
self._moveSelectedAtom)
change_connect(self.yCoordOfSelectedAtom,
SIGNAL("valueChanged(double)"),
self._moveSelectedAtom)
change_connect(self.zCoordOfSelectedAtom,
SIGNAL("valueChanged(double)"),
self._moveSelectedAtom)
connect_checkbox_with_boolean_pref(self.waterCheckBox,
buildModeWaterEnabled_prefs_key)
connect_checkbox_with_boolean_pref(self.highlightingCheckBox,
buildModeHighlightingEnabled_prefs_key)
示例10: _e_eval_lval
def _e_eval_lval(self, env, ipath): # 070119 also print _e_eval_lval calls [maybe untested]
assert env
the_expr = self._e_args[0]
res = the_expr._e_eval_lval(env, ipath)
print_compact_stack(
"debug_evals_of_Expr(%r) eval-lvals it to %r at: " % (the_expr, res)
) # k does this ever happen?
return res
示例11: _do_whycode_reenable
def _do_whycode_reenable( reasons_list_val, whycode):
"""
[private helper function for maintaining whycode,whymsg lists]
"""
res = filter( lambda (code, msg): code != whycode , reasons_list_val ) # zap items with same whycode
if len(res) == len(reasons_list_val) and env.debug():
print_compact_stack("debug fyi: redundant call of _do_whycode_reenable, whycode %r, remaining reasons %r" % \
( whycode, res ) )
return res
示例12: _reverse_neighbor_baseatoms
def _reverse_neighbor_baseatoms(self):
self.neighbor_baseatoms = list(self.neighbor_baseatoms)
self.neighbor_baseatoms.reverse()
if DEBUG_NEIGHBOR_BASEATOMS:
if self.neighbor_baseatoms[0] != -1 or \
self.neighbor_baseatoms[1] != -1:
msg = "reversed %r.neighbor_baseatoms to get %r" % (self, self.neighbor_baseatoms)
print_compact_stack( "\n" + msg + ": ")
return
示例13: _modifyStructure_NEW_SEGMENT_RESIZE
def _modifyStructure_NEW_SEGMENT_RESIZE(self, params): #@ NOT FIXED
"""
This resizes without recreating whole nanotube
Overrides EditCommand._modifystructure.
@attention: is not implemented.
"""
#@TODO: - rename this method from _modifyStructure_NEW_SEGMENT_RESIZE
#to self._modifyStructure, after more testing
#This method is used for debug prefence:
#'Nanotube Segment: resize without recreating whole nanotube'
#see also self.modifyStructure_NEW_SEGMENT_RESIZE
assert self.struct
from utilities.debug import print_compact_stack
print_compact_stack("_modifyStructure_NEW_SEGMENT_RESIZE() not fixed!" )
print "Params =", params
self.nanotube = params #@
length_diff = self._determine_how_to_change_length() #@
if length_diff == 0:
print_compact_stack("BUG: length_diff is always ZERO." )
return
elif length_diff > 0:
print "Nanotube longer by ", length_diff, ", angstroms."
else:
print "Nanotube shorter by ", length_diff, ", angstroms."
return
if numberOfBasePairsToAddOrRemove != 0: #@@@@ Not reached.
resizeEnd_final_position = self._get_resizeEnd_final_position(
ladderEndAxisAtom,
abs(numberOfBasePairsToAddOrRemove),
nanotubeRise )
self.nanotube.modify(self.struct,
length_diff,
ladderEndAxisAtom.posn(),
resizeEnd_final_position)
#Find new end points of structure parameters after modification
#and set these values in the propMgr.
new_end1 , new_end2 = self.struct.nanotube.getEndPoints() #@
params_to_set_in_propMgr = (new_end1,
new_end2)
#TODO: Need to set these params in the PM
#and then self.previousParams = params_to_set_in_propMgr
self.previousParams = params
return
示例14: __init__
def __init__(self):
print_compact_stack(
"warning: fake_Part_drawing_frame is being instantiated: " )
# done in superclass: self.repeated_bonds_dict = None
# This is necessary to remove any chance of self surviving
# for more than one draw of one object (since using an actual
# dict then would make bonds sometimes fail to be drawn).
# Client code must tolerate this value.
return
示例15: _do_whycode_disable
def _do_whycode_disable( reasons_list_val, whycode, whymsg):
"""
[private helper function for maintaining whycode,whymsg lists]
"""
res = filter( lambda (code, msg): code != whycode , reasons_list_val ) # zap items with same whycode
if len(res) < len(reasons_list_val) and env.debug():
print_compact_stack("debug fyi: redundant call of _do_whycode_disable, whycode %r msg %r, preserved reasons %r" % \
( whycode, whymsg, res ) )
res.append( (whycode, whymsg) ) # put the changed one at the end (#k good??)
return res