def __init__(self, projection_table, elem, contents=None): super(MRTAbstractText, self).__init__(projection_table, elem) self.contents_query.change_listener = self._on_changed self._editorModel = None self._incr = IncrementalValueMonitor() if contents is not None: self.setContents(contents)
def __setstate__(self, state): super(GraphVizConfigurationPage, self).__setstate__(state) self._graphVizDir = state['graphVizDir'] self._config = None self._incr = IncrementalValueMonitor() self._refreshConfig()
def __init__(self): self._name = 'value' self._expr = EmbeddedPython2Expr() self._suite = None self._code = None self._incr = IncrementalValueMonitor() self.__change_history__ = None
def __setstate__(self, state): self._name = state['name'] self._expr = state['expr'] self._suite = None self._code = None self._incr = IncrementalValueMonitor() self.__change_history__ = None
def __init__(self, worksheet, blockEditor): super( BlankParagraphEditor, self ).__init__( worksheet, None ) self._style = 'normal' paraAttrs = RichTextAttributes.fromValues({ 'style' : self._style }, None) self._editorModel = WSEditor.RichTextController.WorksheetRichTextController.instance.editorModelParagraph( None, [ '' ], paraAttrs ) self._incr = IncrementalValueMonitor() self._blockEditor = blockEditor
def __init__(self, xs=None): self._items = [] if xs is not None: self._items[:] = xs[:] self.__change_history__ = None self._incr = IncrementalValueMonitor() self.__changeListener = None
def __setstate__(self, state): self._incr = IncrementalValueMonitor() self._schema = None self._tableEditor = None self._tableContent = None self._tableRow = None self._numTableRows = None
class LiterateSuiteDefinition(object): def __init__(self, name='suite', suite=None): self._name = name if suite is None: suite = EmbeddedPython2Suite() self._suite = suite self._incr = IncrementalValueMonitor() self.__change_history__ = None def __getstate__(self): return {'name': self._name, 'suite': self._suite} def __setstate__(self, state): self._name = state['name'] self._suite = state['suite'] self._incr = IncrementalValueMonitor() self.__change_history__ = None def __get_trackable_contents__(self): return [self._suite] def getName(self): return self._name def setName(self, name): oldName = self._name self._name = name self._incr.onChanged() if self.__change_history__ is not None: self.__change_history__.addChange( lambda: self.setName(name), lambda: self.setName(oldName), 'Literate suite definition set name')
def __init__(self, model=None, value=0): super(IntEditorSpinEntry, self).__init__(model, value) self._min = -1000000 self._max = 1000000 self._step = 1 self._page = 10 self._incr = IncrementalValueMonitor()
def __init__(self, expr=None): if expr is None: expr = EmbeddedPython2Expr() self._expr = expr self._incr = IncrementalValueMonitor() self.__change_history__ = None
def __setstate__(self, state): super(IntEditorSpinEntry, self).__setstate__(state) self._min = state.get('min', -1000000) self._max = state.get('max', 1000000) self._step = state.get('step', 1) self._page = state.get('page', 10) self._incr = IncrementalValueMonitor()
def __setstate__(self, state): self._definition = state.get('definition') self._expanded = state.get('expanded', True) if self._definition is None: self._definition = LiterateSuiteDefinition() self._incr = IncrementalValueMonitor() self.__change_history__ = None
def __setstate__(self, state): super( PathsConfigurationPage, self ).__setstate__( state ) self._pluginPaths = state['pluginPaths'] try: self._libraryPaths = state['libraryPaths'] except KeyError: self._libraryPaths = state['pluginRootPaths'] self._incr = IncrementalValueMonitor()
def __init__(self, projection_table, elem, contents=None): super(Block, self).__init__(projection_table, elem) self.contents_query.change_listener = self._on_changed self._editorModel = controller.MallardRichTextController.instance.editorModelBlock( []) self._incr = IncrementalValueMonitor() if contents is not None: self.setContents(contents)
def __init__(self, name='suite', suite=None): self._name = name if suite is None: suite = EmbeddedPython2Suite() self._suite = suite self._incr = IncrementalValueMonitor() self.__change_history__ = None
def __init__(self, definition=None, expanded=True): if definition is None: definition = LiterateSuiteDefinition() self._definition = definition self._expanded = expanded self._incr = IncrementalValueMonitor() self.__change_history__ = None
def __setstate__(self, state): self._suite = state['suite'] self._tableView = state.get( 'tableView', _TableView() ) self._treeView = state.get( 'treeView', _TreeView() ) self._code = None self._incr = IncrementalValueMonitor() self.__change_history__ = None self._tableSchema = None
def __init__(self, projection_table, block): super(_TempBlankPara, self).__init__(projection_table, None) self._block = block self._style = 'normal' self._incr = IncrementalValueMonitor() para_attrs = RichTextAttributes.fromValues({'style': self._style}, None) self._editorModel = controller.MallardRichTextController.instance.editorModelParagraph( [], para_attrs)
def __init__(self, name='test'): super( StandardInlineTest, self ).__init__() self._name = TrackedLiveValue( name ) self._suite = EmbeddedPython2Suite() self.__change_history__ = None self.__passes = None self.__failures = None self._incr = IncrementalValueMonitor()
def __setstate__(self, state): super( StandardInlineTest, self ).__setstate__( state ) self._name = TrackedLiveValue( state['name'] ) self._suite = state['suite'] self.__change_history__ = None self.__passes = None self.__failures = None self._incr = IncrementalValueMonitor()
def __init__(self, name, showBanner=True): self._incr = IncrementalValueMonitor( self ) self._blocks = [] self._currentPythonModule = Python2.py25NewModuleAsRoot() self._before = [] self._after = [] self._module = imp.new_module( name ) self._showBanner = showBanner LoadBuiltins.loadBuiltins( self._module )
def __init__(self): self._suite = EmbeddedPython2Suite() self._code = None self._incr = IncrementalValueMonitor() self.__change_history__ = None self._tableSchema = None self._tableView = _TableView() self._treeView = _TreeView()
class InlinePythonCodeAbstractView(NodeAbstractView): STYLE_MINIMAL_RESULT = 0 STYLE_RESULT = 1 STYLE_CODE_AND_RESULT = 2 STYLE_EDITABLE_CODE_AND_RESULT = 3 _styleToName = { STYLE_MINIMAL_RESULT: 'minimal_result', STYLE_RESULT: 'result', STYLE_CODE_AND_RESULT: 'code_result', STYLE_EDITABLE_CODE_AND_RESULT: 'editable_code_result' } _nameToStyle = { 'minimal_result': STYLE_MINIMAL_RESULT, 'result': STYLE_RESULT, 'code_result': STYLE_CODE_AND_RESULT, 'editable_code_result': STYLE_EDITABLE_CODE_AND_RESULT } def __init__(self, worksheet, model): NodeAbstractView.__init__(self, worksheet, model) self._incr = IncrementalValueMonitor(self) self._result = None def getExpr(self): return self._model['expr'] def getStyle(self): name = self._model['style'] try: return self._nameToStyle[name] except KeyError: return self.STYLE_CODE_AND_RESULT def isCodeVisible(self): style = self.getStyle() return style == self.STYLE_CODE_AND_RESULT or style == self.STYLE_EDITABLE_CODE_AND_RESULT def isCodeEditable(self): style = self.getStyle() return style == self.STYLE_EDITABLE_CODE_AND_RESULT def isResultMinimal(self): style = self.getStyle() return style == self.STYLE_MINIMAL_RESULT def getResult(self): self._incr.onAccess() return self._result def _refreshResults(self, module): self._result = Execution.getResultOfEvaluationWithinModule( self.getExpr(), module) self._incr.onChanged()
class _TableView (object): def __init__(self): self._incr = IncrementalValueMonitor() self._schema = None self._tableEditor = None self._tableContent = None self._tableRow = None self._numTableRows = None def initialise(self, schema): self._schema = schema self._tableEditor = GenericTableEditor( [ v._name for v in schema._monitoredExpressions ], True, True, False, False ) self._tableContent = GenericTableModel( lambda: '', lambda x: x ) self._tableRow = None self._numTableRows = None def __getstate__(self): return { None : None } def __setstate__(self, state): self._incr = IncrementalValueMonitor() self._schema = None self._tableEditor = None self._tableContent = None self._tableRow = None self._numTableRows = None def begin(self): state = self._tableRow self._numTableRows = self._numTableRows + 1 if self._numTableRows is not None else 0 self._tableRow = self._numTableRows return state def end(self, state): self._tableRow = state self._incr.onChanged() def logValue(self, monitoredExpression, value): index = self._schema._monitoredExpressionToindex[monitoredExpression] self._tableContent.set( index, self._tableRow, value ) def __present__(self, fragment, inheritedState): self._incr.onAccess() return self._tableEditor.editTable( self._tableContent ) if self._tableEditor is not None else Blank()
class ConsoleBlock (object): def __init__(self, pythonModule, execResult): self._incr = IncrementalValueMonitor( self ) self._pythonModule = pythonModule self._execResult = execResult def getPythonModule(self): self._incr.onAccess() return self._pythonModule def getExecResult(self): self._incr.onAccess() return self._execResult def __present__(self, fragment, inheritedState): pythonModule = self.getPythonModule() executionResult = self.getExecResult() caughtException = executionResult.getCaughtException() result = executionResult.getResult() streams = executionResult.getStreams() moduleView = StyleSheet.style( Primitive.editable( False ) ).applyTo( Python2.python2EditorPerspective.applyTo( pythonModule ) ) caughtExceptionView = ApplyPerspective.defaultPerspective( caughtException ) if caughtException is not None else None resultView = ApplyPerspective.defaultPerspective( result[0] ) if result is not None else None code = _pythonModuleBorderStyle.applyTo( Border( moduleView.alignHExpand() ).alignHExpand() ) outputContents = [] for stream in streams: if stream.name == 'out': outputContents.append( execStdout( stream.richString, True ) ) elif stream.name == 'err': outputContents.append( execStderr( stream.richString, True ) ) else: raise ValueError, 'Unreckognised stream \'{0}\''.format( stream.name ) if caughtExceptionView is not None: outputContents.append( execException( caughtExceptionView ) ) if resultView is not None: outputContents.append( execResult( resultView ) ) outputColumn = _blockOutputStyle.applyTo( Column( outputContents ).alignHExpand() ) return _blockStyle.applyTo( Border( Column( [ code, outputColumn ] ) ) ).alignHExpand()
class LiterateExpression(object): def __init__(self, expr=None): if expr is None: expr = EmbeddedPython2Expr() self._expr = expr self._incr = IncrementalValueMonitor() self.__change_history__ = None def __getstate__(self): return {'expr': self._expr} def __setstate__(self, state): self._expr = state['expr'] self._incr = IncrementalValueMonitor() self.__change_history__ = None def __get_trackable_contents__(self): return [self._expr] def __py_evalmodel__(self, codeGen): return self._expr.model def __py_replacement__(self): return deepcopy(self._expr.model['expr']) def _new_reference(self): return LiterateExpression(self._expr) def __present__(self, fragment, inheritedState): self._incr.onAccess() exprPres = self._expr header = Row([ self._angleQuoteStyle(Label(u'\u00ab')), self._angleQuoteStyle(Label(u'\u00bb')), Spacer(9.0, 0.0) ]).withDragSource(_dragSource) return ObjectBorder(Row([header.alignVCentre(), exprPres])) _angleQuoteStyle = StyleSheet.style( Primitive.foreground(Color(0.15, 0.15, 0.45)), Primitive.fontBold(True), Primitive.fontSize(12))
class _TreeView (object): def __init__(self): self._incr = IncrementalValueMonitor() self.initialise() def __getstate__(self): return { None : None } def __setstate__(self, state): self._incr = IncrementalValueMonitor() self.initialise() def initialise(self): self._incr.onChanged() self._rootFrames = [] self._currentFrame = None def begin(self): self._incr.onChanged() # Open a new frame prevFrame = self._currentFrame self._currentFrame = _Frame() if prevFrame is not None: prevFrame.childFrames.append( self._currentFrame ) else: self._rootFrames.append( self._currentFrame ) return prevFrame def end(self, state): prevFrame = state self._currentFrame = prevFrame def logValue(self, monitoredExpression, value): self._incr.onChanged() if self._currentFrame is not None: self._currentFrame.values.logValue( monitoredExpression, value ) def __present__(self, fragment, inheritedState): self._incr.onAccess() valuesLive = LiveValue( Blank() ) tree = Column( [ x._presentFrameSubtree( valuesLive ) for x in self._rootFrames ] ) return Column( [ tree, Spacer( 0.0, 10.0 ), valuesLive ] )
def __init__(self, field, object_instance, wrapped_source_value): super(EvalFieldInstance, self).__init__(field, object_instance, wrapped_source_value) self.__change_history__ = None if wrapped_source_value is not None: source_value = wrapped_source_value[0] if isinstance(source_value, _EvalFieldState): constantValue = source_value.constantValue expr = source_value.expr else: constantValue = source_value expr = None else: constantValue = field._getDefaultValue() expr = None self._live = TrackedLiveValue(constantValue) self._expr = expr self.__incr = IncrementalValueMonitor()
class BlankParagraphEditor (AbstractViewSchema.NodeAbstractView): def __init__(self, worksheet, blockEditor): super( BlankParagraphEditor, self ).__init__( worksheet, None ) self._style = 'normal' paraAttrs = RichTextAttributes.fromValues({ 'style' : self._style }, None) self._editorModel = WSEditor.RichTextController.WorksheetRichTextController.instance.editorModelParagraph( None, [ '' ], paraAttrs ) self._incr = IncrementalValueMonitor() self._blockEditor = blockEditor def getText(self): self._incr.onAccess() return '' def setContents(self, contents): self._editorModel.setModelContents( WSEditor.RichTextController.WorksheetRichTextController.instance, contents ) if len( contents ) == 0: return elif len( contents ) == 1 and contents[0] == '': return p = ParagraphEditor.newParagraph( contents, self._style ) self._blockEditor.appendEditorNode( p ) def getStyle(self): self._incr.onAccess() return self._style def setStyle(self, style): self._style = style self._incr.onChanged() def _refreshResults(self, module): pass
class ConstantDefinition(object): def __init__(self): self._target = EmbeddedPython2Target() self._value = EmbeddedPython2Expr() self._incr = IncrementalValueMonitor() self.__change_history__ = None def __getstate__(self): return {'target': self._target, 'value': self._value} def __setstate__(self, state): self._target = state['target'] self._value = state['value'] self._incr = IncrementalValueMonitor() self.__change_history__ = None def __get_trackable_contents__(self): return [self.target, self.value] def __copy__(self): d = ConstantDefinition() d.target = self.target d.value = self.value return d def __deepcopy__(self, memo): d = ConstantDefinition() d.target = deepcopy(self.target, memo) d.value = deepcopy(self.value, memo) return d def _getTarget(self): self._incr.onAccess() return self._target def _setTarget(self, target): self._target = deepcopy(target) self._incr.onChanged() def _getValue(self): self._incr.onAccess() return self._value def _setValue(self, value): self._value = deepcopy(value) self._incr.onChanged() target = property(_getTarget, _setTarget) value = property(_getValue, _setValue)