convert CfDef to string
975736
protected static String cfdefToString(CfDef cfDef) throws IOException
    {
        assert cfDef != null;
        // this is so awful it's kind of cool!
        TSerializer serializer = new TSerializer(new TBinaryProtocol.Factory());
        try
        {
            return Hex.bytesToHex(serializer.serialize(cfDef));
        }
        catch (TException e)
        {
            throw new IOException(e);
        }
    }
904196
def _cf_string_to_unicode(value):
    
    value_as_void_p = ctypes.cast(value, ctypes.POINTER(ctypes.c_void_p))

    string = CoreFoundation.CFStringGetCStringPtr(
        value_as_void_p,
        CFConst.kCFStringEncodingUTF8
    )
    if string is None:
        buffer = ctypes.create_string_buffer(1024)
        result = CoreFoundation.CFStringGetCString(
            value_as_void_p,
            buffer,
            1024,
            CFConst.kCFStringEncodingUTF8
        )
        if not result:
            raise OSError('Error copying C string from CFStringRef')
        string = buffer.value
    if string is not None:
        string = string.decode('utf-8')
    return string
893697
function bufferToString (buf) {
  const a = bufferToTuples(buf)
  const b = tuplesToStringTuples(a)
  return stringTuplesToString(b)
}
1236773
public static CFuncRef from(String def) {
    if (def == null || def.isEmpty()) {
      return NOP;
    }
    String[] parts = def.split("=");
    assert parts.length == 2 : "Input should be `lang:key=funcName`";
    String[] langParts = parts[0].split(":");
    assert langParts.length == 2 : "Input should be `lang:key=funcName`";
    return new CFuncRef(langParts[0], langParts[1], parts[1]);
  }
688044
private String createString(String f)
    {
        StringBuilder sb = new StringBuilder();
        switch (resType)
        {
            case CUresourcetype.CU_RESOURCE_TYPE_ARRAY:
                sb.append("hArray="+array_hArray+f);
                break;

            case  CUresourcetype.CU_RESOURCE_TYPE_MIPMAPPED_ARRAY:
                sb.append("hMipmappedArray="+mipmap_hMipmappedArray+f);
                break;

            case  CUresourcetype.CU_RESOURCE_TYPE_LINEAR:
                sb.append("devPtr="+linear_devPtr+f);
                sb.append("format="+CUarray_format.stringFor(linear_format)+f);
                sb.append("numChannels="+linear_numChannels+f);
                sb.append("sizeInBytes="+linear_sizeInBytes+f);
                break;

            case  CUresourcetype.CU_RESOURCE_TYPE_PITCH2D:
                sb.append("devPtr="+pitch2D_devPtr+f);
                sb.append("format="+CUarray_format.stringFor(pitch2D_format)+f);
                sb.append("numChannels="+pitch2D_numChannels+f);
                sb.append("width="+pitch2D_width+f);
                sb.append("height="+pitch2D_height+f);
                sb.append("pitchInBytes="+pitch2D_pitchInBytes+f);
                break;

            default:
                sb.append("INVALID");
        }
        return sb.toString();
    }
1014623
def _parse_fc(self, f, natom, dim):
        

        ndim = np.prod(dim)
        fc = np.zeros((natom, natom * ndim, 3, 3), dtype='double', order='C')
        for k, l, i, j in np.ndindex((3, 3, natom, natom)):
            line = f.readline()
            for i_dim in range(ndim):
                line = f.readline()
                # fc[i, j * ndim + i_dim, k, l] = float(line.split()[3])
                fc[j, i * ndim + i_dim, l, k] = float(line.split()[3])
        return fc
592316
def mode_to_str(mode):
    
    if mode == tf.estimator.ModeKeys.TRAIN:
        return "train"
    if mode == tf.estimator.ModeKeys.EVAL:
        return "eval"
    if mode == tf.estimator.ModeKeys.PREDICT:
        return "predict"
    return "unknown"
843246
protected final String toFFDCString(byte[] toDump, int start, int length)
  {
    StringBuffer result = new StringBuffer();
    for (int lineStart = 0; lineStart < length; lineStart += 32)
    {
      int lineEnd = Math.min(lineStart + 32, length);
      StringBuffer hex = new StringBuffer();
      StringBuffer ascii = new StringBuffer();
      for (int i = lineStart; i < lineEnd; i++)
      {
        int b = toDump[start + i];
        b = (b + 256) % 256; // Make sure bytes become unsigned

        // Add b to the hex StringBuffer
        int c1 = b / 16;
        int c2 = b % 16;

        hex.append((char) (c1 < 10 ? '0' + c1 : 'a' + c1 - 10));
        hex.append((char) (c2 < 10 ? '0' + c2 : 'a' + c2 - 10));

        // Add b to the ascii StringBuffer, if printable
        if ((b >= 0x20 && b <= 0x7e))
          ascii.append((char) b);
        else
          ascii.append('.');
        if (i % 32 == 15)
        {
          hex.append("  ");
            ascii.append("  ");
        }
      }

      // We need to pad the hex string with sufficient spaces
      // to align the ascii string nicely.
      int pad = 32 - (lineEnd - lineStart);

      // This formula aligns to the end of the hex block, plus a
      // trailing space. Honest.
      for (int i = 0; i < pad; i++)
      {
        hex.append("  ");
        if (i % 32 == 16)
        {
          hex.append("  ");
        }
      }

      hex.append("   ");

      // Before we output the line, output the offset of the
      // start of the line.
      String offset = "0000" + Integer.toHexString(lineStart + start);
      offset = offset.substring(offset.length() - 4);
      result.append(offset);
      result.append(":  ");

      // Finally, output the line
      result.append(hex.toString());
      result.append(ascii.toString());
      result.append(lineSeparator);
    }

    return result.toString();
  }
267096
def SaveDataToFD(self, raw_data, fd):
    """"""
    fd.write(yaml.Dump(raw_data).encode("utf-8"))
770846
def mk_fmtfld(nt_item, joinchr=" ", eol="\n"):
    """"""
    fldstrs = []
    # Default formats based on fieldname
    fld2fmt = {
        'hdrgo' : lambda f: "{{{FLD}:1,}}".format(FLD=f),
        'dcnt' : lambda f: "{{{FLD}:6,}}".format(FLD=f),
        'level' : lambda f: "L{{{FLD}:02,}}".format(FLD=f),
        'depth' : lambda f: "D{{{FLD}:02,}}".format(FLD=f),
    }
    for fld in nt_item._fields:
        if fld in fld2fmt:
            val = fld2fmt[fld](fld)
        else:
            val = "{{{FLD}}}".format(FLD=fld)
        fldstrs.append(val)
    return "{LINE}{EOL}".format(LINE=joinchr.join(fldstrs), EOL=eol)
63546
private String createString(String f)
    {
        return
            "func="+func+f+
            "gridDimX="+gridDimX+f+
            "gridDimY="+gridDimY+f+
            "gridDimZ="+gridDimZ+f+
            "blockDimX="+blockDimX+f+
            "blockDimY="+blockDimY+f+
            "blockDimZ="+blockDimZ+f+
            "sharedMemBytes="+sharedMemBytes+f+
            "kernelParams="+kernelParams+f+
            "extra="+extra;
    }
1259182
def _sec_to_str(t):
    
    from functools import reduce
    return "%d:%02d:%02d.%02d" % \
        reduce(lambda ll, b: divmod(ll[0], b) + ll[1:],
               [(t*100,), 100, 60, 60])
1051239
private String createString(String f)
    {
        return
            "dst="+dst+f+
            "pitch="+pitch+f+
            "value="+value+f+
            "elementSize="+elementSize+f+
            "width="+width+f+
            "height="+height;
    }
814096
def codes_get_string_array(handle, key, size, length=None):
    # type: (cffi.FFI.CData, bytes, int, int) -> T.List[bytes]
    
    if length is None:
        length = codes_get_string_length(handle, key)
    values_keepalive = [ffi.new('char[]', length) for _ in range(size)]
    values = ffi.new('char*[]', values_keepalive)
    size_p = ffi.new('size_t *', size)
    _codes_get_string_array(handle, key.encode(ENC), values, size_p)
    return [ffi.string(values[i]).decode(ENC) for i in range(size_p[0])]
163559
def get_string(cfunc, *args):
    
    cstr = get_ctype("const char**", cfunc, *args)
    return backend.ffi.string(cstr).decode() if cstr else None
1070807
def cftype_to_value(cftype):
    """"""
    if not cftype:
        return None
    typeID = cf.CFGetTypeID(cftype)
    if typeID in known_cftypes:
        convert_function = known_cftypes[typeID]
        return convert_function(cftype)
    else:
        return cftype
1231687
public final String toFFDCString(Object[] objects)
  {
    StringBuffer buffer = new StringBuffer();
    buffer.append('{');
    if (objects == null)
    {
      buffer.append("<null>");
    }
    else
    {
      for (int i = 0; i < objects.length; i++)
      {
        Object value = objects[i];
        buffer.append((value == objects ? "<this array>" : toFFDCStringSingleObject(value)) + lineSeparator);

        if (i > multiple_object_count_to_ffdc)
        {
          buffer.append("........contd");
          break;
        }
      }
    }
    buffer.append('}');

    return buffer.toString();
  }