code: def get_mapping(self):  # TODO: rename to _as_dict
          
          return {
              key: val
              for key, val in self.__dict__.iteritems()
              if val
          }
docs: Convert the class to dict.
  
          Returns:
              dict: Copy of ``self.__dict__``.