1

I recently stumbled upon a tool called Augeas. As far as I understand the tool can be used to create an abstract file type independent tree that can be manipulated where the lens is an intermediary.

I want to try to use it for file conversion. Is that possible? Say, I want to convert yaml into xml. How would I do that?

A simple example of such conversion using augtool would be nice.

user3081519
  • 2,659
  • 5
  • 25
  • 35

1 Answers1

0

Augeas can theoretically be used for file conversion, although it is not its primary goal.

This will mean manipulating the Augeas tree (typically using aug_cp) to create a new tree from the existing one. When it comes to exporting as XML, Augeas also has a aug_to_xml call which exports any Augeas tree into an XML document.

Now when it comes to your specific need though, there is no YAML Augeas lens (because it is currently not possible to write one).

raphink
  • 3,625
  • 1
  • 28
  • 39
  • Thanks for the info, is yaml lens not possible because it has no solid specification? Or is there any other reason? – user3081519 Mar 15 '16 at 17:18
  • YAML has a very precise and solid specification (unlike a lot of other formats supported by Augeas). The problem is that YAML relies on consistent indentation levels for hash levels. Augeas cannot currently remember the number of spaces in an entry to model that format. – raphink Mar 17 '16 at 08:34
  • Note there is a YAML lense now, but it isnt very capable. It depends on the complexity of the yaml structure. I've submitted two patches and raised one bug, and it still isnt quite good enough for my input document. augeas has undocumented and limited recursion and a few other hidden features, so it might be possible to get closer now by using those. – John Vandenberg Nov 05 '17 at 01:46