Example #1
0
    def close_window(self):
        """close the window corresponding to this frame

        **NOTE:** The owner must call the frame's cleanup method before
        calling this method to close the actual GUI frame

        **INPUTS**

        *none*

        **OUTPUTS**

        *none*
        """
        if not self.closing:
# this should never happen, but if it does, report the error and make
# the best of it
            msg = 'frame received close_window without prior cleanup\n'
            debug.critical_warning(msg)
# this is diagnostic information associated with the critical warning, 
# not a trace, so it should always be printed
#            debug.print_call_stack()
            self.cleanup()
        debug.trace('WaxFrameBase.close_window', 'calling self.Close')
        self.Close()
Example #2
0
    def close_window(self):
        """close the window corresponding to this frame

        **NOTE:** The owner must call the frame's cleanup method before
        calling this method to close the actual GUI frame

        **INPUTS**

        *none*

        **OUTPUTS**

        *none*
        """
        if not self.closing:
# this should never happen, but if it does, report the error and make
# the best of it
            msg = 'frame received close_window without prior cleanup\n'
            debug.critical_warning(msg)
# this is diagnostic information associated with the critical warning, 
# not a trace, so it should always be printed
#            debug.print_call_stack()
            self.cleanup()
        debug.trace('WaxFrameBase.close_window', 'calling self.Close')
        self.Close()
    def contents_cbk(self, text):
        
        """External editor invokes that callback to inform VoiceCode
        of the buffer contents.

        **INPUTS**
                
        STR *text* -- Text to be inserted

        **OUTPUTS**
        
        *none* -- 
        """
        if self._not_cached('get_text'):               
# if we don't have the buffer contents cached, we don't know what text 
# was replaced, so we can't create a reverse diff, and all our previous
# change_history is invalid
            debug.trace('SourceBuffWithDiffs.contents_cbk',
                'not cached')

# if the text isn't cached, then the stacks should already be clear,
# but just for good measure
            self.clear_stacks()
            if self.undoing:
                # this should REALLY never happen, but if it does,
                # there is no good way to handle it
                msg = 'WARNING: SourceBuffWithDiffs.contents_cbk called\n'
                msg = msg + 'while undoing changes, with NO CACHED TEXT.\n'
                msg = msg +'.  Please report this as a bug\n'
                debug.critical_warning(msg)
            SourceBuffCached.contents_cbk(self, text)
            return
        
# otherwise, treat this as an insert callback
        start, end, change = \
               find_difference.find_difference(self.cache['get_text'], text)
        self.insert_cbk(range = (start, end), text = change)
Example #4
0
    def cleanup(self):
        """method to cleanup circular references by cleaning up 
        any children, and then removing the reference to the parent

        **INPUTS**

        *none*

        **OUTPUTS**

        *none*
        """
        #        debug.trace_call_stack('OwnerObject.cleanup')
        self.remove_other_references()
        debug.trace('OwnerObject.cleanup', 'after remove_other_references')

        reversed_names = self.owned_objects
        reversed_names.reverse()
        msg_prefix = 'Warning: while cleaning up %s,\nunable to cleanup ' \
            % repr(self)
        for name in reversed_names:
            if self.__dict__.has_key(name):
                attribute = self.__dict__[name]
                debug.trace(
                    'OwnerObject.cleanup',
                    'cleanup %s with value %s' % (name, repr(attribute)))
                if attribute == None:
                    continue
                if type(attribute) == types.ListType:
                    rr = range(len(attribute))
                    rr.reverse()
                    for i in rr:
                        error_msg = self._cleanup_object(attribute[i])
                        if error_msg != None:
                            error_msg = 'element %d of attribute %s\n%s\n' \
                                % (i, name, error_msg)
                            debug.critical_warning(msg_prefix + error_msg)
                        else:
                            del attribute[i]
                elif type(attribute) == types.DictType:
                    sorted = attribute.keys()
                    sorted.sort()
                    for key in sorted:
                        error_msg = self._cleanup_object(attribute[key])
                        if error_msg != None:
                            error_msg = 'value for key %s of attribute %s\n%s\n' \
                                % (str(key), name, error_msg)
                            debug.critical_warning(msg_prefix + error_msg)
                        else:
                            del attribute[key]
                elif (type(attribute) == types.InstanceType
                      or debug.isinstance_of_some_class(attribute)):
                    error_msg = self._cleanup_object(attribute)
                    if error_msg != None:
                        error_msg = 'attribute %s\n%s\n' \
                            % (name, error_msg)
                        debug.critical_warning(msg_prefix + error_msg)
                    else:
                        del self.__dict__[name]
                else:
                    error_msg = 'because it is not an object, ' \
                        + 'but has type %s' % (type(attribute))
                    error_msg = 'attribute %s\n%s\n' \
                        % (name, error_msg)
                    debug.critical_warning(msg_prefix + error_msg)
                    del self.__dict__[name]

            else:
                error_msg = 'because the attribute does not exist\n'
                error_msg = 'attribute %s\n%s' \
                    % (name, error_msg)
                debug.critical_warning(msg_prefix + error_msg)

        for grandparent in self.grandparents:
            if self.__dict__.has_key(grandparent):
                del self.__dict__[grandparent]

        if self.parent_name != None \
                and self.__dict__.has_key(self.parent_name):
            del self.__dict__[self.parent_name]
        debug.trace('OwnerObject.cleanup',
                    'cleanup of %s finished' % repr(self))
Example #5
0
    def cleanup(self):
        """method to cleanup circular references by cleaning up 
        any children, and then removing the reference to the parent

        **INPUTS**

        *none*

        **OUTPUTS**

        *none*
        """
#        debug.trace_call_stack('OwnerObject.cleanup')
        self.remove_other_references()
        debug.trace('OwnerObject.cleanup', 'after remove_other_references')
    
        reversed_names = self.owned_objects
        reversed_names.reverse()
        msg_prefix = 'Warning: while cleaning up %s,\nunable to cleanup ' \
            % repr(self)
        for name in reversed_names:
            if self.__dict__.has_key(name):
                attribute = self.__dict__[name]
                debug.trace('OwnerObject.cleanup', 
                    'cleanup %s with value %s' % (name, repr(attribute)))
                if attribute == None:
                    continue
                if type(attribute) == types.ListType:
                    rr = range(len(attribute))
                    rr.reverse()
                    for i in rr:
                        error_msg = self._cleanup_object(attribute[i])
                        if error_msg != None:
                            error_msg = 'element %d of attribute %s\n%s\n' \
                                % (i, name, error_msg)
                            debug.critical_warning(msg_prefix + error_msg)
                        else:
                            del attribute[i]
                elif type(attribute) == types.DictType:
                    sorted = attribute.keys()
                    sorted.sort()
                    for key in sorted:
                        error_msg = self._cleanup_object(attribute[key])
                        if error_msg != None:
                            error_msg = 'value for key %s of attribute %s\n%s\n' \
                                % (str(key), name, error_msg)
                            debug.critical_warning(msg_prefix + error_msg)
                        else:
                            del attribute[key]
                elif (type(attribute) == types.InstanceType or 
                      debug.isinstance_of_some_class(attribute)):
                    error_msg = self._cleanup_object(attribute)
                    if error_msg != None:
                        error_msg = 'attribute %s\n%s\n' \
                            % (name, error_msg)
                        debug.critical_warning(msg_prefix + error_msg)
                    else:
                        del self.__dict__[name]
                else:
                    error_msg = 'because it is not an object, ' \
                        + 'but has type %s' % (type(attribute))
                    error_msg = 'attribute %s\n%s\n' \
                        % (name, error_msg)
                    debug.critical_warning(msg_prefix + error_msg)
                    del self.__dict__[name]

            else:
                error_msg = 'because the attribute does not exist\n'
                error_msg = 'attribute %s\n%s' \
                    % (name, error_msg)
                debug.critical_warning(msg_prefix + error_msg)
        
        for grandparent in self.grandparents:
            if self.__dict__.has_key(grandparent):
                del self.__dict__[grandparent]

        if self.parent_name != None \
                and self.__dict__.has_key(self.parent_name):
            del self.__dict__[self.parent_name]
        debug.trace('OwnerObject.cleanup', 'cleanup of %s finished' % repr(self))