original_docstring: Encode dat as a class or instance.
docstring: Encode dat as a class or instance.
docstring_tokens: Encode dat as a class or instance .
code: def encode_class_or_instance(self, dat, new_obj):
      """Encode dat as a class or instance."""
      if is_instance(dat):
        if hasattr(dat, '__class__'):
          # common case ...
          class_name = get_name(dat.__class__)
        else:
          # super special case for something like
          # "from datetime import datetime_CAPI" in Python 3.2,
          # which is some weird 'PyCapsule' type ...
          # http://docs.python.org/release/3.1.5/c-api/capsule.html
          class_name = get_name(type(dat))
  
        if hasattr(dat, '__str__') and \
           (not dat.__class__.__str__ is object.__str__): # make sure it's not the lame default __str__
          # N.B.: when objects are being constructed, this call
          # might fail since not all fields have yet been populated
          try:
            pprint_str = str(dat)
          except:
            pprint_str = '<incomplete object>'
  
          new_obj.extend(['INSTANCE_PPRINT', class_name, pprint_str])
          return # bail early
        else:
          new_obj.extend(['INSTANCE', class_name])
          # don't traverse inside modules, or else risk EXPLODING the visualization
          if class_name == 'module':
            return
      else:
        superclass_names = [e.__name__ for e in dat.__bases__ if e is not object]
        new_obj.extend(['CLASS', get_name(dat), superclass_names])
  
      # traverse inside of its __dict__ to grab attributes
      # (filter out useless-seeming ones, based on anecdotal observation):
      hidden = ('__doc__', '__module__', '__return__', '__dict__',
          '__locals__', '__weakref__', '__qualname__')
      if hasattr(dat, '__dict__'):
        user_attrs = sorted([e for e in dat.__dict__ if e not in hidden])
      else:
        user_attrs = []
  
      for attr in user_attrs:
        new_obj.append([self.encode(attr, None), self.encode(dat.__dict__[attr], None)])
code_tokens: def encode_class_or_instance ( self , dat , new_obj ) : if is_instance ( dat ) : if hasattr ( dat , '__class__' ) : class_name = get_name ( dat . __class__ ) else : class_name = get_name ( type ( dat ) ) if hasattr ( dat , '__str__' ) and ( not dat . __class__ . __str__ is object . __str__ ) : try : pprint_str = str ( dat ) except : pprint_str = '<incomplete object>' new_obj . extend ( [ 'INSTANCE_PPRINT' , class_name , pprint_str ] ) return else : new_obj . extend ( [ 'INSTANCE' , class_name ] ) if class_name == 'module' : return else : superclass_names = [ e . __name__ for e in dat . __bases__ if e is not object ] new_obj . extend ( [ 'CLASS' , get_name ( dat ) , superclass_names ] ) hidden = ( '__doc__' , '__module__' , '__return__' , '__dict__' , '__locals__' , '__weakref__' , '__qualname__' ) if hasattr ( dat , '__dict__' ) : user_attrs = sorted ( [ e for e in dat . __dict__ if e not in hidden ] ) else : user_attrs = [ ] for attr in user_attrs : new_obj . append ( [ self . encode ( attr , None ) , self . encode ( dat . __dict__ [ attr ] , None ) ] )
short_docstring: Encode dat as a class or instance.
short_docstring_tokens: Encode dat as a class or instance .
comment: """Encode dat as a class or instance."""$SEP$# common case ...$SEP$# super special case for something like$SEP$# "from datetime import datetime_CAPI" in Python 3.2,$SEP$# which is some weird 'PyCapsule' type ...$SEP$# http://docs.python.org/release/3.1.5/c-api/capsule.html$SEP$# make sure it's not the lame default __str__$SEP$# N.B.: when objects are being constructed, this call$SEP$# might fail since not all fields have yet been populated$SEP$# bail early$SEP$# don't traverse inside modules, or else risk EXPLODING the visualization$SEP$# traverse inside of its __dict__ to grab attributes$SEP$# (filter out useless-seeming ones, based on anecdotal observation):