回答了所有播放属性
python -c 'import ansible.playbook.play as P; print P.Play()._valid_attrs.keys()'
但是努力以相同的方式检索任务属性。
以下代码段不返回任何内容:
python -c 'import ansible.playbook.task as T ; T.Task()._valid_attrs;'
我依靠this code进行反向工程。
答案 0 :(得分:0)
缺少const catalog = [
{
title: "Masculine T-Shirts 2017",
code:"1101",
page:"http://www.blablabla.com/catalog/1101/",
data: [[
{
code:"1101-1",
name:"Masculine T-Shirt product 1",
page:"http://www.blablabla.com/catalog/1101/product/1101-1/",
description:"description of product 1",
},
{
code:"1101-2",
name:"Masculine T-Shirt product 2",
page:"http://www.blablabla.com/catalog/1101/product/1101-2/",
description:"description of product 2",
},
{
code:"1101-3",
name:"Masculine T-Shirt product 3",
page:"http://www.blablabla.com/catalog/1101/product/1101-3/",
description:"description of product 3",
}
]]
},
{
title: "Masculine T-Shirts 2018",
code:"1203",
page:"http://www.blablabla.com/catalog/1203/",
data: [[
{
code:"1203-1",
name:"Masculine T-Shirt product 1",
page:"http://www.blablabla.com/catalog/1203/product/1203-1/",
description:"description of product 1",
},
{
code:"1203-2",
name:"Masculine T-Shirt product 2",
page:"http://www.blablabla.com/catalog/1203/product/1203-2/",
description:"description of product 2",
},
{
code:"1203-3",
name:"Masculine T-Shirt product 3",
page:"http://www.blablabla.com/catalog/1203/product/1203-3/",
description:"description of product 3",
},
{
code:"1203-4",
name:"Masculine T-Shirt product 4",
page:"http://www.blablabla.com/catalog/1203/product/1203-4/",
description:"description of product 4",
}
]]
},
{
title: "Masculine socks 2018",
code:"1304",
page:"http://www.blablabla.com/catalog/1304/",
data: [[
{
code:"1304-1",
name:"Masculine socks product 1",
page:"http://www.blablabla.com/catalog/1304/product/1304-1/",
description:"description of socks product 1",
},
{
code:"1304-2",
name:"Masculine socks product 2",
page:"http://www.blablabla.com/catalog/1304/product/1304-2/",
description:"description of socks product 2",
}
]]
},
]
let savedList = ["1304-2","1101-3","1304-1"];
let savedCatalog = catalog.map(item =>
Object.assign({}, item, {data: [
item.data[0].filter(dat => savedList.includes(dat.code))
]})
).filter(item => item.data[0].length);
console.log(savedCatalog);
方法:
print