Skip to content

Commit

Permalink
Top printers should print absolute path too
Browse files Browse the repository at this point in the history
  • Loading branch information
dpino committed Jul 6, 2017
1 parent cf8a7ef commit a516bf8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/lib/yang/data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -892,20 +892,28 @@ function xpath_printer_from_grammar(production, print_default, root)
function top_printers.array(production)
local serialize = value_serializer(production.element_type)
return function(data, file, indent)
local count = 1
for _,v in ipairs(data) do
file:write(root.."[position()="..count.."]")
file:write(' ')
file:write(serialize(v))
file:write('\n')
file:write(';\n')
count = count + 1
end
return file:flush()
end
end
function top_printers.scalar(production)
local serialize = value_serializer(production.argument_type)
return function(data, file)
file:write(root)
file:write(' ')
file:write(serialize(data))
file:write(';\n')
return file:flush()
end
end

return assert(top_printers[production.type])(production)
end
xpath_printer_from_grammar = util.memoize(xpath_printer_from_grammar)
Expand Down

0 comments on commit a516bf8

Please sign in to comment.