V3.0 - How to upgrade ResourceImportMetadata?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By thinkrapido
:warning: Old Version Published before Godot 3 was released.

Hi,

I want to use Tiled Map Importer Plugin. It is only available for 2.x now.

How can I refactor the code to get the job done?

func _on_ImportTilemap_confirmed():
var alert = get_node("ErrorAlert")
var valid = validate_options()
if valid != "OK":
	alert.set_text(valid)
	alert.popup_centered_minsize()
	return

var imd = ResourceImportMetadata.new()
imd.add_source(get_node("MainDialog/Origin/Path").get_text())
imd.set_option("post_script", get_node("MainDialog/PostImportScript/Path").get_text().strip_edges())

for opt_code in options:
	var opt = options[opt_code]
	if opt.type == TreeItem.CELL_MODE_CHECK:
		imd.set_option(opt_code, opt.item.is_checked(1))
	elif opt.type == TreeItem.CELL_MODE_STRING:
		imd.set_option(opt_code, opt.item.get_text(1))
	elif opt.type == TreeItem.CELL_MODE_CUSTOM:
		imd.set_option(opt_code, opt.item.get_metadata(1))

var f = File.new()
imd.set_source_md5(0, f.get_md5(imd.get_source_path(0)))

var err = import_plugin.import(get_node("MainDialog/Target/Path").get_text(), imd)

if err != "OK":
	alert.set_text("Error when importing:\n%s" % [err])
	alert.popup_centered_minsize()
	return

hide()