def lipd_write(_json, path):
    """
    Saves current state of LiPD object data. Outputs to a LiPD file.
    Steps: create tmp, create bag dir, get dsn, splice csv from json, write csv, clean json, write json, create bagit,
        zip up bag folder, place lipd in target dst, move to original dir, delete tmp

    :param dict _json: Metadata
    :param str path: Destination path
    :return none:
    """
    # Json is pass by reference. Make a copy so we don't mess up the original data.
    _json_tmp = copy.deepcopy(_json)
    dir_original = os.getcwd()
    try:
        dir_tmp = create_tmp_dir()
        dir_bag = os.path.join(dir_tmp, "bag")
        os.mkdir(dir_bag)
        os.chdir(dir_bag)
        _dsn = get_dsn(_json_tmp)
        _dsn_lpd = _dsn + ".lpd"
        _json_tmp, _csv = get_csv_from_metadata(_dsn, _json_tmp)
        write_csv_to_file(_csv)
        _json_tmp = rm_values_fields(_json_tmp)
        _json_tmp = put_tsids(_json_tmp)
        _json_tmp = idx_name_to_num(_json_tmp)
        write_json_to_file(_json_tmp)
        create_bag(dir_bag)
        rm_file_if_exists(path, _dsn_lpd)
        zipper(root_dir=dir_tmp, name="bag", path_name_ext=os.path.join(path, _dsn_lpd))
        os.chdir(dir_original)
        shutil.rmtree(dir_tmp)
    except Exception as e:
        logger_lipd.error("lipd_write: {}".format(e))
        print("Error: lipd_write: {}".format(e))
    return
def lipd_write ( _json , path ) : _json_tmp = copy . deepcopy ( _json ) dir_original = os . getcwd ( ) try : dir_tmp = create_tmp_dir ( ) dir_bag = os . path . join ( dir_tmp , "bag" ) os . mkdir ( dir_bag ) os . chdir ( dir_bag ) _dsn = get_dsn ( _json_tmp ) _dsn_lpd = _dsn + ".lpd" _json_tmp , _csv = get_csv_from_metadata ( _dsn , _json_tmp ) write_csv_to_file ( _csv ) _json_tmp = rm_values_fields ( _json_tmp ) _json_tmp = put_tsids ( _json_tmp ) _json_tmp = idx_name_to_num ( _json_tmp ) write_json_to_file ( _json_tmp ) create_bag ( dir_bag ) rm_file_if_exists ( path , _dsn_lpd ) zipper ( root_dir = dir_tmp , name = "bag" , path_name_ext = os . path . join ( path , _dsn_lpd ) ) os . chdir ( dir_original ) shutil . rmtree ( dir_tmp ) except Exception as e : logger_lipd . error ( "lipd_write: {}" . format ( e ) ) print ( "Error: lipd_write: {}" . format ( e ) ) return
Saves current state of LiPD object data. Outputs to a LiPD file.
    Steps: create tmp, create bag dir, get dsn, splice csv from json, write csv, clean json, write json, create bagit,
        zip up bag folder, place lipd in target dst, move to original dir, delete tmp

    :param dict _json: Metadata
    :param str path: Destination path
    :return none: