Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / cobblersettings.aug
1 (*
2     Parse the /etc/cobbler/settings file  which is in
3     YAML 1.0 format.
4
5     The lens can handle the following constructs
6     * key: value
7     * key: "value"
8     * key: 'value'
9     * key: [value1, value2]
10     * key:
11        - value1
12        - value2
13     * key:
14        key2: value1
15        key3: value2
16
17     Author: Bryan Kearney
18
19     About: License
20       This file is licensed under the LGPL v2+, like the rest of Augeas.
21 *)
22 module CobblerSettings =
23     autoload xfm
24
25     let kw = /[a-zA-Z0-9_]+/
26     (* TODO Would be better if this stripped off the "" and '' characters *)
27     let kv = /([^]['", \t\n#:@-]+|"[^"\n]*"|'[^'\n]*')/
28
29     let lbr = del /\[/ "["
30     let rbr = del /\]/ "]"
31     let colon = del /[ \t]*:[ \t]*/ ": "
32     let dash = del /-[ \t]*/ "- "
33     (* let comma = del /,[ \t]*(\n[ \t]+)?/ ", " *)
34     let comma = del /[ \t]*,[ \t]*/ ", "
35
36     let eol_only = del /\n/ "\n"
37
38     (* TODO Would be better to make items a child of a document *)
39     let docmarker = /-{3}/
40
41     let eol   = Util.eol
42     let comment = Util.comment
43     let empty   = Util.empty
44     let indent = del /[ \t]+/ "\t"
45     let ws = del /[ \t]*/ " "
46
47     let value_list = Build.opt_list [label "item" . store kv] comma
48     let setting = [key kw . colon . store kv] . eol
49     let simple_setting_suffix = store kv . eol
50     let setting_list_suffix =  [label "sequence" . lbr . ws . (value_list . ws)? . rbr ] . eol
51     let indendented_setting_list_suffix =  eol_only . (indent . setting)+
52     let indented_list_suffix =  [label "list" . eol_only . ([ label "value" . indent . dash  . store kv] . eol)+]
53
54     (* Break out setting because of a current bug in augeas *)
55     let nested_setting = [key kw . colon . (
56                                             (* simple_setting_suffix | *)
57                                             setting_list_suffix |
58                                             indendented_setting_list_suffix |
59                                             indented_list_suffix
60                                             )
61                         ]
62
63     let document = [label "---" . store docmarker] . eol
64
65     let lns = (document | comment | empty | setting | nested_setting )*
66
67     let xfm = transform lns (incl "/etc/cobbler/settings")
68
69
70 (* Local Variables: *)
71 (* mode: caml *)
72 (* End: *)