Back to index

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

List of all members.

Public Member Functions

def __init__
def repr1
def repr_string
def repr_instance
def repr
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

Detailed Description

Class for safely making a text representation of a Python object.

Definition at line 963 of file pydoc.py.


Constructor & Destructor Documentation

def pydoc.TextRepr.__init__ (   self)

Reimplemented from reprlib.Repr.

Definition at line 965 of file pydoc.py.

00965 
00966     def __init__(self):
00967         Repr.__init__(self)
00968         self.maxlist = self.maxtuple = 20
00969         self.maxdict = 10
00970         self.maxstring = self.maxother = 100

Here is the caller graph for this function:


Member Function Documentation

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

Reimplemented in pydoc.HTMLRepr.

Definition at line 53 of file reprlib.py.

00053 
00054     def repr(self, x):
00055         return self.repr1(x, self.maxlevel)

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from reprlib.Repr.

Definition at line 971 of file pydoc.py.

00971 
00972     def repr1(self, x, level):
00973         if hasattr(type(x), '__name__'):
00974             methodname = 'repr_' + '_'.join(type(x).__name__.split())
00975             if hasattr(self, methodname):
00976                 return getattr(self, methodname)(x, level)
00977         return 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.TextRepr.repr_instance (   self,
  x,
  level 
)

Reimplemented from reprlib.Repr.

Definition at line 989 of file pydoc.py.

00989 
00990     def repr_instance(self, x, level):
00991         try:
00992             return cram(stripid(repr(x)), self.maxstring)
00993         except:
00994             return '<%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.TextRepr.repr_string (   self,
  x,
  level 
)

Definition at line 978 of file pydoc.py.

00978 
00979     def repr_string(self, x, level):
00980         test = cram(x, self.maxstring)
00981         testrepr = repr(test)
00982         if '\\' in test and '\\' not in replace(testrepr, r'\\', ''):
00983             # Backslashes are only literal in the string and are never
00984             # needed to make any special characters, so show a raw string.
00985             return 'r' + testrepr[0] + test + testrepr[0]
00986         return 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 968 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 967 of file pydoc.py.

reprlib.Repr.maxlong [inherited]

Definition at line 50 of file reprlib.py.

Reimplemented from reprlib.Repr.

Definition at line 969 of file pydoc.py.

reprlib.Repr.maxset [inherited]

Definition at line 46 of file reprlib.py.

Reimplemented from reprlib.Repr.

Definition at line 969 of file pydoc.py.

Reimplemented from reprlib.Repr.

Definition at line 967 of file pydoc.py.

Definition at line 987 of file pydoc.py.


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