human
Complete this python program:
def hb_write(path_or_open_file, m, hb_info=None):
assistant
#Here is the Python code you requested.

    """Write HB-format file.
    Parameters
    path_or_open_file : path-like or file-like
    If a file-like object, it is used as-is. Otherwise it is opened
    before writing.
    m : sparse-matrix
    the sparse matrix to write
    hb_info : HBInfo
    contains the meta-data for write
    Returns
    None
    Notes
    At the moment not the full Harwell-Boeing format is supported. Supported
    features are:
    - assembled, non-symmetric, real matrices
    - integer for pointer/indices
    - exponential format for float values, and int format
    """
    if (hb_info is None):
        hb_info = HBInfo.from_data(m)
    def _set_matrix(fid):
        hb = HBFile(fid, hb_info)
        return hb.write_matrix(m)
    if hasattr(path_or_open_file, 'write'):
        return _set_matrix(path_or_open_file)
    else:
        with open(path_or_open_file, 'w') as f:
            return _set_matrix(f)