I need to create a function from the following bunch of code:
jsHelperFunctions = """
function getTreeList(treeId) {
var $tree = $(treeId);
var itemsList = [];
var treeList = $($tree.jstree().get_json($tree, {
flat: true
})).each(function(i, val) {
itemsList.push($tree.jstree().get_node(val.id))
})
return itemsList;
}
function getItemByItemCode(itemCode, itemsList) {
return itemsList.filter(val => val.original.account_code ==
itemCode)[0]
}"""
and this is the one line of code my supervisor gave me:
treeList = driver.execute_script(jsHelperFunctions + """ return
getTreeList("#tree");""")
Tried something like this, but I am not sure about that (first function):
def get_tree_list(treeId):
tree = treeId
itemsList = []
treeList = tree.jstree().get_json(tree, flat: true).each(function(i, val)
itemsList.push(tree.jstree().get_node(val.id))
return itemsList
Also what is about val
and the flat
in Py?