Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
pydoc.HTMLRepr Class Reference
Inheritance diagram for pydoc.HTMLRepr:
Inheritance graph
[legend]
Collaboration diagram for pydoc.HTMLRepr:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def escape
def repr
def repr1
def repr_string
def repr_instance
def repr_tuple
def repr_list
def repr_array
def repr_set
def repr_frozenset
def repr_deque
def repr_dict
def repr_str
def repr_int

Public Attributes

 maxlist
 maxtuple
 maxdict
 maxstring
 maxother
 maxlevel
 maxarray
 maxset
 maxfrozenset
 maxdeque
 maxlong

Static Public Attributes

 repr_str = repr_string
 repr_unicode = repr_string

Detailed Description

Class for safely making an HTML representation of a Python object.

Definition at line 383 of file pydoc.py.


Constructor & Destructor Documentation

def pydoc.HTMLRepr.__init__ (   self)

Reimplemented from reprlib.Repr.

Definition at line 385 of file pydoc.py.

00385 
00386     def __init__(self):
00387         Repr.__init__(self)
00388         self.maxlist = self.maxtuple = 20
00389         self.maxdict = 10
00390         self.maxstring = self.maxother = 100

Here is the caller graph for this function:


Member Function Documentation

def pydoc.HTMLRepr.escape (   self,
  text 
)

Definition at line 391 of file pydoc.py.

00391 
00392     def escape(self, text):
00393         return replace(text, '&', '&amp;', '<', '&lt;', '>', '&gt;')

Here is the call graph for this function:

Here is the caller graph for this function:

def pydoc.HTMLRepr.repr (   self,
  object 
)

Reimplemented from reprlib.Repr.

Definition at line 394 of file pydoc.py.

00394 
00395     def repr(self, object):
00396         return Repr.repr(self, object)

Here is the caller graph for this function:

def pydoc.HTMLRepr.repr1 (   self,
  x,
  level 
)

Reimplemented from reprlib.Repr.

Definition at line 397 of file pydoc.py.

00397 
00398     def repr1(self, x, level):
00399         if hasattr(type(x), '__name__'):
00400             methodname = 'repr_' + '_'.join(type(x).__name__.split())
00401             if hasattr(self, methodname):
00402                 return getattr(self, methodname)(x, level)
00403         return self.escape(cram(stripid(repr(x)), self.maxother))

Here is the call graph for this function:

Here is the caller graph for this function:

def reprlib.Repr.repr_array (   self,
  x,
  level 
) [inherited]

Definition at line 85 of file reprlib.py.

00085 
00086     def repr_array(self, x, level):
00087         header = "array('%s', [" % x.typecode
00088         return self._repr_iterable(x, level, header, '])', self.maxarray)

Here is the call graph for this function:

def reprlib.Repr.repr_deque (   self,
  x,
  level 
) [inherited]

Definition at line 98 of file reprlib.py.

00098 
00099     def repr_deque(self, x, level):
00100         return self._repr_iterable(x, level, 'deque([', '])', self.maxdeque)

Here is the call graph for this function:

def reprlib.Repr.repr_dict (   self,
  x,
  level 
) [inherited]

Definition at line 101 of file reprlib.py.

00101 
00102     def repr_dict(self, x, level):
00103         n = len(x)
00104         if n == 0: return '{}'
00105         if level <= 0: return '{...}'
00106         newlevel = level - 1
00107         repr1 = self.repr1
00108         pieces = []
00109         for key in islice(_possibly_sorted(x), self.maxdict):
00110             keyrepr = repr1(key, newlevel)
00111             valrepr = repr1(x[key], newlevel)
00112             pieces.append('%s: %s' % (keyrepr, valrepr))
00113         if n > self.maxdict: pieces.append('...')
00114         s = ', '.join(pieces)
00115         return '{%s}' % (s,)

Here is the call graph for this function:

def reprlib.Repr.repr_frozenset (   self,
  x,
  level 
) [inherited]

Definition at line 93 of file reprlib.py.

00093 
00094     def repr_frozenset(self, x, level):
00095         x = _possibly_sorted(x)
00096         return self._repr_iterable(x, level, 'frozenset([', '])',
00097                                    self.maxfrozenset)

Here is the call graph for this function:

def pydoc.HTMLRepr.repr_instance (   self,
  x,
  level 
)

Reimplemented from reprlib.Repr.

Definition at line 417 of file pydoc.py.

00417 
00418     def repr_instance(self, x, level):
00419         try:
00420             return self.escape(cram(stripid(repr(x)), self.maxstring))
00421         except:
00422             return self.escape('<%s instance>' % x.__class__.__name__)

Here is the call graph for this function:

Here is the caller graph for this function:

def reprlib.Repr.repr_int (   self,
  x,
  level 
) [inherited]

Definition at line 125 of file reprlib.py.

00125 
00126     def repr_int(self, x, level):
00127         s = builtins.repr(x) # XXX Hope this isn't too slow...
00128         if len(s) > self.maxlong:
00129             i = max(0, (self.maxlong-3)//2)
00130             j = max(0, self.maxlong-3-i)
00131             s = s[:i] + '...' + s[len(s)-j:]
00132         return s

def reprlib.Repr.repr_list (   self,
  x,
  level 
) [inherited]

Definition at line 82 of file reprlib.py.

00082 
00083     def repr_list(self, x, level):
00084         return self._repr_iterable(x, level, '[', ']', self.maxlist)

Here is the call graph for this function:

def reprlib.Repr.repr_set (   self,
  x,
  level 
) [inherited]

Definition at line 89 of file reprlib.py.

00089 
00090     def repr_set(self, x, level):
00091         x = _possibly_sorted(x)
00092         return self._repr_iterable(x, level, 'set([', '])', self.maxset)

Here is the call graph for this function:

def reprlib.Repr.repr_str (   self,
  x,
  level 
) [inherited]

Definition at line 116 of file reprlib.py.

00116 
00117     def repr_str(self, x, level):
00118         s = builtins.repr(x[:self.maxstring])
00119         if len(s) > self.maxstring:
00120             i = max(0, (self.maxstring-3)//2)
00121             j = max(0, self.maxstring-3-i)
00122             s = builtins.repr(x[:i] + x[len(x)-j:])
00123             s = s[:i] + '...' + s[len(s)-j:]
00124         return s

def pydoc.HTMLRepr.repr_string (   self,
  x,
  level 
)

Definition at line 404 of file pydoc.py.

00404 
00405     def repr_string(self, x, level):
00406         test = cram(x, self.maxstring)
00407         testrepr = repr(test)
00408         if '\\' in test and '\\' not in replace(testrepr, r'\\', ''):
00409             # Backslashes are only literal in the string and are never
00410             # needed to make any special characters, so show a raw string.
00411             return 'r' + testrepr[0] + self.escape(test) + testrepr[0]
00412         return re.sub(r'((\\[\\abfnrtv\'"]|\\[0-9]..|\\x..|\\u....)+)',
00413                       r'<font color="#c040c0">\1</font>',
00414                       self.escape(testrepr))

Here is the call graph for this function:

def reprlib.Repr.repr_tuple (   self,
  x,
  level 
) [inherited]

Definition at line 79 of file reprlib.py.

00079 
00080     def repr_tuple(self, x, level):
00081         return self._repr_iterable(x, level, '(', ')', self.maxtuple, ',')

Here is the call graph for this function:


Member Data Documentation

reprlib.Repr.maxarray [inherited]

Definition at line 44 of file reprlib.py.

reprlib.Repr.maxdeque [inherited]

Definition at line 48 of file reprlib.py.

Reimplemented from reprlib.Repr.

Definition at line 388 of file pydoc.py.

Definition at line 47 of file reprlib.py.

reprlib.Repr.maxlevel [inherited]

Definition at line 41 of file reprlib.py.

Reimplemented from reprlib.Repr.

Definition at line 387 of file pydoc.py.

reprlib.Repr.maxlong [inherited]

Definition at line 50 of file reprlib.py.

Reimplemented from reprlib.Repr.

Definition at line 389 of file pydoc.py.

reprlib.Repr.maxset [inherited]

Definition at line 46 of file reprlib.py.

Reimplemented from reprlib.Repr.

Definition at line 389 of file pydoc.py.

Reimplemented from reprlib.Repr.

Definition at line 387 of file pydoc.py.

Definition at line 415 of file pydoc.py.

Definition at line 423 of file pydoc.py.


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