Imported Upstream version 1.7.0
[platform/upstream/augeas.git] / lenses / pylonspaste.aug
1 (*
2 Module: PylonsPaste
3  Parses Pylons Paste ini configuration files.
4
5 Author: Andrew Colin Kissa <andrew@topdog.za.net>
6  Baruwa Enterprise Edition http://www.baruwa.com
7
8 About: License
9  This file is licensed under the LGPL v2+.
10
11 About: Configuration files
12  This lens applies to /etc/baruwa See <filter>.
13 *)
14
15 module Pylonspaste =
16 autoload xfm
17
18 (************************************************************************
19  * Group: USEFUL PRIMITIVES
20  *************************************************************************)
21
22 let comment  = IniFile.comment IniFile.comment_re IniFile.comment_default
23
24 let sep = IniFile.sep "=" "="
25
26 let eol = Util.eol
27
28 let optspace = del /\n/ "\n"
29
30 let entry_re = ( /[A-Za-z][:#A-Za-z0-9._-]+/)
31
32 let plugin_re = /[A-Za-z][;:#A-Za-z0-9._-]+/
33
34 let plugins_kw = /plugins/
35
36 let debug_kw = /debug/
37
38 let normal_opts = entry_re - (debug_kw|plugins_kw)
39
40 let del_opt_ws =  del /[\t ]*/ ""
41
42 let new_ln_sep = optspace . del_opt_ws . store plugin_re
43
44 let plugins_multiline = sep . counter "items" . [ seq "items" . new_ln_sep]*
45
46 let sto_multiline = optspace . Sep.opt_space . store (Rx.space_in . (/[ \t]*\n/ . Rx.space . Rx.space_in)*)
47
48 (************************************************************************
49  * Group:                       ENTRY
50  *************************************************************************)
51
52 let set_option = Util.del_str "set "
53 let no_inline_comment_entry (kw:regexp) (sep:lens) (comment:lens) =
54                          [ set_option . key debug_kw . sep . IniFile.sto_to_eol . eol ]
55                          | [ key plugins_kw . plugins_multiline . eol]
56                          | [ key kw . sep . IniFile.sto_to_eol? . eol ]
57                          | comment
58
59 let entry   = no_inline_comment_entry normal_opts sep comment
60
61 (************************************************************************
62  *                        RECORD
63  *************************************************************************)
64
65 let title   = IniFile.title IniFile.record_re
66
67 let record  = IniFile.record title entry
68
69 (************************************************************************
70  * Group:                        LENS & FILTER
71  *************************************************************************)
72
73 let lns = IniFile.lns record comment
74
75 let filter = incl "/etc/baruwa/*.ini"
76
77 let xfm = transform lns filter
78