Hi Xavier,

The short answer is, no, this is not possible. Augeas cannot currently
memorize a string is has met (except in the case of square lenses).

In general, Augeas' goal is not to model the meaning of the configuration
file, but rather the form of it. In the same way, there is no way to
interpret "include" statements, you just map them. Interpreting such things
should be done in the code using Augeas (through XPath expressions), not in
the lens itself.


Cheers,

Raphaël




On Thu, Feb 11, 2016 at 10:16 AM, Mol, Xavier (SCC) <[email protected]>
wrote:

> Hello Augeas experts,
>
> at the end, I have pasted a broken Augeas module definition, which
> demonstrates what I want to achieve. Currently, the below pasted module,
> instead of adding subsequent members to the same group, always creates a
> new tree node with one child node. However, given a source text, I want to
> look for repetitions and bundle them together in a subtree. The problem is,
> that part of the repeated pattern is variable. Can I somehow memorize a
> matched string in Augeas and use it for pattern matching?
>
> Thank you for your time,
> Xavier.
>
>
> module Test_for_consecutive_matches =
>
> let source =
> "create group1
> create group2
> addto group1 memberA
> addto group1 memberB
> addto group2 memberX
> addto group2 memberY
> addto group2 memberZ
> "
>
> let create = [ key "create" . Sep.space . store Rx.word . Util.eol ]
>
> let addto = [ key "addto" . Sep.space . store Rx.word . Sep.space .
>               counter "members" . [ seq "members" . store Rx.word ] .
>               Util.eol
>             ]
>
> let lns = ( create | addto )*
>
> test lns get source =
> { "create" = "group1" }
> { "create" = "group2" }
> { "addto" = "group1"
>   { "1" = "memberA" }
>   { "2" = "memberB" }
> }
> { "addto" = "group2"
>   { "1" = "memberX" }
>   { "2" = "memberY" }
>   { "3" = "memberZ" }
> }
>
>
>
> ****
> Karlsruher Institute of Technology (KIT)
> Steinbuch Centre for Computing (SCC)
>
> B. Sc. Xavier Mol
> GridKa Storage Administrator and Support Manager
>
> Hermann-von-Helmholtz-Platz 1
> Geb. 449
> 76344 Eggenstein-Leopoldshafen
> Phone: +49 721 608 23041
> Email: [email protected]
> www.kit.edu
> KIT - University of the State of Baden-Württemberg and National
> Large-scale Research Center of the Helmholtz Association
> "Since 2010, the KIT has been certified as a family-friendly university."
> ****
>
>
> _______________________________________________
> augeas-devel mailing list
> [email protected]
> https://www.redhat.com/mailman/listinfo/augeas-devel
>



-- 
Raphaël Pinson
Infrastructure Developer & Training Leader
+33 458 482 013

Camptocamp France
Savoie Technolac
BP 352
48, avenue du Lac du Bourget
73372 Le Bourget du Lac, Cedex
www.camptocamp.com
_______________________________________________
augeas-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/augeas-devel

Reply via email to