Exemple #1
0
    def as_dict ( self, item, indent, name = '<dict>' ):
        """ Returns the dictionary *item* pretty_printed as a string.
        """
        if len( indent ) > 0:
            return super( LocalsItem, self ).as_dict( item, indent, name )

        if len( item ) == 0:
            return ''

        items     = item.items()
        n         = 0
        separator = ','
        if self.lod > 0:
            n         = max_len( item.keys(), MaxAlignment )
            separator = ''

        try:
            items.sort( lambda l, r: cmp( l[0], r[0] ) )
        except:
            pass

        return (separator.join( [
            '\n%s = %s' % ( key.ljust( n ), self.as_str( value ).strip() )
            for key, value in items
        ] ))
    def _item_contents_default ( self ):
        caller_len = max_len(
            [ frame.f_code.co_name for frame in self.item ]
        ) + 2

        call_stack = []
        for frame in self.item:
            line           = frame.f_lineno
            caller         = frame.f_code.co_name
            file_name      = frame.f_code.co_filename
            cc1, tr1       = self._source_info_for( file_name, line, frame )
            cc2, file_name = self._file_info_for( file_name, line )
            call_stack.append(
                '%s%s\x004 | %s%s\x004 at \x00C%d%s' %
                ( cc1, (caller + '\x004').ljust( caller_len ), cc2, file_name,
                  line, tr1 )
            )

        return '\n'.join( call_stack )