Back to index

moin  1.9.0~rc2
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
MoinMoin.support.werkzeug.debug.repr.DebugReprGenerator Class Reference

List of all members.

Public Member Functions

def __init__
def regex_repr
def string_repr
def dict_repr
def object_repr
def dispatch_repr
def fallback_repr
def repr
def dump_object
def dump_locals

Static Public Attributes

tuple list_repr = _sequence_repr_maker('[', ']', list)
tuple tuple_repr = _sequence_repr_maker('(', ')', tuple)
tuple set_repr = _sequence_repr_maker('set([', '])', set)
tuple frozenset_repr = _sequence_repr_maker('frozenset([', '])', frozenset)
tuple deque_repr

Private Member Functions

def _sequence_repr_maker

Private Attributes

 _stack

Detailed Description

Definition at line 88 of file repr.py.


Constructor & Destructor Documentation

Definition at line 90 of file repr.py.

00090 
00091     def __init__(self):
00092         self._stack = []


Member Function Documentation

def MoinMoin.support.werkzeug.debug.repr.DebugReprGenerator._sequence_repr_maker (   left,
  right,
  base = object(),
  limit = 8 
) [private]

Definition at line 93 of file repr.py.

00093 
00094     def _sequence_repr_maker(left, right, base=object(), limit=8):
00095         def proxy(self, obj, recursive):
00096             if recursive:
00097                 return _add_subclass_info(left + '...' + right, obj, base)
00098             buf = [left]
00099             have_extended_section = False
00100             for idx, item in enumerate(obj):
00101                 if idx:
00102                     buf.append(', ')
00103                 if idx == limit:
00104                     buf.append('<span class="extended">')
00105                     have_extended_section = True
00106                 buf.append(self.repr(item))
00107             if have_extended_section:
00108                 buf.append('</span>')
00109             buf.append(right)
00110             return _add_subclass_info(u''.join(buf), obj, base)
00111         return proxy

Here is the call graph for this function:

def MoinMoin.support.werkzeug.debug.repr.DebugReprGenerator.dict_repr (   self,
  d,
  recursive,
  limit = 5 
)

Definition at line 145 of file repr.py.

00145 
00146     def dict_repr(self, d, recursive, limit=5):
00147         if recursive:
00148             return _add_subclass_info(u'{...}', d, dict)
00149         buf = ['{']
00150         have_extended_section = False
00151         for idx, (key, value) in enumerate(d.iteritems()):
00152             if idx:
00153                 buf.append(', ')
00154             if idx == limit - 1:
00155                 buf.append('<span class="extended">')
00156                 have_extended_section = True
00157             buf.append('<span class="pair"><span class="key">%s</span>: '
00158                        '<span class="value">%s</span></span>' %
00159                        (self.repr(key), self.repr(value)))
00160         if have_extended_section:
00161             buf.append('</span>')
00162         buf.append('}')
00163         return _add_subclass_info(u''.join(buf), d, dict)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 168 of file repr.py.

00168 
00169     def dispatch_repr(self, obj, recursive):
00170         if obj is helper:
00171             return helper.get_help(None)
00172         if isinstance(obj, (int, long, float, complex)):
00173             return u'<span class="number">%r</span>' % obj
00174         if isinstance(obj, basestring):
00175             return self.string_repr(obj)
00176         if isinstance(obj, RegexType):
00177             return self.regex_repr(obj)
00178         if isinstance(obj, list):
00179             return self.list_repr(obj, recursive)
00180         if isinstance(obj, tuple):
00181             return self.tuple_repr(obj, recursive)
00182         if isinstance(obj, set):
00183             return self.set_repr(obj, recursive)
00184         if isinstance(obj, frozenset):
00185             return self.frozenset_repr(obj, recursive)
00186         if isinstance(obj, dict):
00187             return self.dict_repr(obj, recursive)
00188         if deque is not None and isinstance(obj, deque):
00189             return self.deque_repr(obj, recursive)
00190         return self.object_repr(obj)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 237 of file repr.py.

00237 
00238     def dump_locals(self, d):
00239         items = [(key, self.repr(value)) for key, value in d.items()]
00240         return render_template('dump_object.html', items=items,
00241                                title='Local variables in frame', repr=None)

Here is the call graph for this function:

Definition at line 214 of file repr.py.

00214 
00215     def dump_object(self, obj):
00216         repr = items = None
00217         if isinstance(obj, dict):
00218             title = 'Contents of'
00219             items = []
00220             for key, value in obj.iteritems():
00221                 if not isinstance(key, basestring):
00222                     items = None
00223                     break
00224                 items.append((key, self.repr(value)))
00225         if items is None:
00226             items = []
00227             repr = self.repr(obj)
00228             for key in dir(obj):
00229                 try:
00230                     items.append((key, self.repr(getattr(obj, key))))
00231                 except:
00232                     pass
00233             title = 'Details for'
00234         title += ' ' + object.__repr__(obj)[1:-1]
00235         return render_template('dump_object.html', items=items,
00236                                title=title, repr=repr)

Here is the call graph for this function:

Definition at line 191 of file repr.py.

00191 
00192     def fallback_repr(self):
00193         try:
00194             info = ''.join(format_exception_only(*sys.exc_info()[:2]))
00195         except:
00196             info = '?'
00197         return u'<span class="brokenrepr">&lt;broken repr (%s)&gt;' \
00198                u'</span>' % escape(info.decode('utf-8', 'ignore').strip())

Here is the caller graph for this function:

Definition at line 164 of file repr.py.

00164 
00165     def object_repr(self, obj):
00166         return u'<span class="object">%s</span>' % \
00167                escape(repr(obj).decode('utf-8', 'replace'))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 121 of file repr.py.

00121 
00122     def regex_repr(self, obj):
00123         pattern = repr(obj.pattern).decode('string-escape', 'ignore')
00124         if pattern[:1] == 'u':
00125             pattern = 'ur' + pattern[1:]
00126         else:
00127             pattern = 'r' + pattern
00128         return u're.compile(<span class="string regex">%s</span>)' % pattern

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 199 of file repr.py.

00199 
00200     def repr(self, obj):
00201         recursive = False
00202         for item in self._stack:
00203             if item is obj:
00204                 recursive = True
00205                 break
00206         self._stack.append(obj)
00207         try:
00208             try:
00209                 return self.dispatch_repr(obj, recursive)
00210             except:
00211                 return self.fallback_repr()
00212         finally:
00213             self._stack.pop()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 129 of file repr.py.

00129 
00130     def string_repr(self, obj, limit=70):
00131         buf = ['<span class="string">']
00132         escaped = escape(obj)
00133         a = repr(escaped[:limit])
00134         b = repr(escaped[limit:])
00135         if isinstance(obj, unicode):
00136             buf.append('u')
00137             a = a[1:]
00138             b = b[1:]
00139         if b != "''":
00140             buf.extend((a[:-1], '<span class="extended">', b[1:], '</span>'))
00141         else:
00142             buf.append(a)
00143         buf.append('</span>')
00144         return _add_subclass_info(u''.join(buf), obj, (str, unicode))

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 91 of file repr.py.

Initial value:
_sequence_repr_maker('<span class="module">collections.'
                                          '</span>deque([', '])', deque)

Definition at line 117 of file repr.py.

Definition at line 115 of file repr.py.

Definition at line 112 of file repr.py.

Definition at line 114 of file repr.py.

Definition at line 113 of file repr.py.


The documentation for this class was generated from the following file: