parameters: (i, encoding=None, encoding_errors='strict')
return_statement: return instance_str
docstring: :type i: ClassInstance
docstring_summary: :type i: ClassInstance
docstring_tokens: : type i : ClassInstance
function: def dump_instance(i, encoding=None, encoding_errors='strict'):
      """ :type i: ClassInstance """
      # TODO: migrate to templating?
      ret = []
      cl = i.class_layout
      cd = cl.class_definition
      ret.append("classname: %s" % cd.class_name)
      ret.append("super: %s" % cd.super_class_name)
      ret.append("key: %s" % str(i.key))
      ret.append("timestamp1: %s" % i.ts1)
      ret.append("timestamp2: %s" % i.ts2)
      ret.append("properties:")
      for propname, prop in i.properties.items():
          quals = ",".join(["{:s}={:s}".format(str(k), str(v)) for k, v in prop.qualifiers.items()])
          if quals != "":
              quals = "  [{:s}]".format(quals)
              ret.append(quals)
  
          if prop.is_initialized:
              ret.append("  {key:s}={value:s}".format(
                  key=prop.name,
                  value=str(prop.value)))
              if prop.is_default_value:
                  ret.append("    default value: true")
          else:
              ret.append("  {key:s}=nil".format(key=prop.name))
          ret.append("")
  
      instance_str = "\n".join(ret)
  
      # encode to specified encoding (which returns a byte array),
      # and then decode back to a string
      if encoding:
          instance_str = instance_str.encode(encoding=encoding, errors=encoding_errors).decode(encoding)
  
      return instance_str
function_tokens: def dump_instance ( i , encoding = None , encoding_errors = 'strict' ) : # TODO: migrate to templating? ret = [ ] cl = i . class_layout cd = cl . class_definition ret . append ( "classname: %s" % cd . class_name ) ret . append ( "super: %s" % cd . super_class_name ) ret . append ( "key: %s" % str ( i . key ) ) ret . append ( "timestamp1: %s" % i . ts1 ) ret . append ( "timestamp2: %s" % i . ts2 ) ret . append ( "properties:" ) for propname , prop in i . properties . items ( ) : quals = "," . join ( [ "{:s}={:s}" . format ( str ( k ) , str ( v ) ) for k , v in prop . qualifiers . items ( ) ] ) if quals != "" : quals = "  [{:s}]" . format ( quals ) ret . append ( quals ) if prop . is_initialized : ret . append ( "  {key:s}={value:s}" . format ( key = prop . name , value = str ( prop . value ) ) ) if prop . is_default_value : ret . append ( "    default value: true" ) else : ret . append ( "  {key:s}=nil" . format ( key = prop . name ) ) ret . append ( "" ) instance_str = "\n" . join ( ret ) # encode to specified encoding (which returns a byte array), # and then decode back to a string if encoding : instance_str = instance_str . encode ( encoding = encoding , errors = encoding_errors ) . decode ( encoding ) return instance_str