[Patches] Include meta directive support for ConfigParser.py
Al Williams
alaric@warhead.org.uk
Sat, 27 May 2000 22:43:44 +0100 (BST)
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.
--0-711169532-959463824=:759
Content-Type: TEXT/PLAIN; charset=US-ASCII
Enclosed is a context diff that adds the ability to include other files
from a config file.
I have made use of the illegaility of colons in section headers to add a
new syntax for meta directives:
[directive: arguments ]
The only directive implemented in the patch is include:
[include:/usr/local/etc/myprog.config]
There's a new error that can arise if an unknown directive is found. I've
structured the code so as to allow the addition of directives.
PS: What do people think about a neta directive to use a BSD db file as a
section, huh?
[mail-aliases]
root: alaric
[hash:/etc/aliases.db]
Enjoy!
ABW
-----------------B<--------------
I confirm that, to the best of my knowledge and belief, this
contribution is free of any claims of third parties under
copyright, patent or other rights or interests ("claims"). To
the extent that I have any such claims, I hereby grant to CNRI a
nonexclusive, irrevocable, royalty-free, worldwide license to
reproduce, distribute, perform and/or display publicly, prepare
derivative versions, and otherwise use this contribution as part
of the Python software and its related documentation, or any
derivative versions thereof, at no cost to CNRI or its licensed
users, and to authorize others to do so.
I acknowledge that CNRI may, at its sole discretion, decide
whether or not to incorporate this contribution in the Python
software and its related documentation. I further grant CNRI
permission to use my name and other identifying information
provided to CNRI by me for use in connection with the Python
software and its related documentation.
--
http://www.rfc.net/
http://www.alaric-williams.com/
http://www.warhead.org.uk/
alaric@alaric-williams.com
ph3@r mI sk1llz l3st I 0wn j00
--0-711169532-959463824=:759
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="ConfigParser.py.diff"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.NEB.4.10.10005272243440.759@love.warhead.org.uk>
Content-Description:
Content-Disposition: attachment; filename="ConfigParser.py.diff"
KioqIENvbmZpZ1BhcnNlci5weQlTYXQgTWF5IDI3IDIyOjE2OjQyIDIwMDAN
Ci0tLSBteUNvbmZpZ1BhcnNlci5weQlTYXQgTWF5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mLmZp
bGVuYW1lID0gZmlsZW5hbWUNCisgICAgICAgICBzZWxmLmxpbmVubyA9IGxp
bmVubw0KKyAgICAgICAgIHNlbGYuZGlyZWN0aXZlID0gZGlyZWN0aXZlDQor
IA0KICBjbGFzcyBQYXJzaW5nRXJyb3IoRXJyb3IpOg0KICAgICAgZGVmIF9f
aW5pdF9fKHNlbGYsIGZpbGVuYW1lKToNCiAgICAgICAgICBFcnJvci5fX2lu
aXRfXyhzZWxmLCAnRmlsZSBjb250YWlucyBwYXJzaW5nIGVycm9yczogJXMn
ICUgZmlsZW5hbWUpDQoqKioqKioqKioqKioqKioNCioqKiAyNTUsMjY3ICoq
KioNCiAgICAgICAgICBpZiByYXc6DQogICAgICAgICAgICAgIHJldHVybiBy
YXd2YWwNCiAgDQogICAgICAgICAgdmFsdWUgPSByYXd2YWwgICAgICAgICAg
ICAgICAgICAjIE1ha2UgaXQgYSBwcmV0dHkgdmFyaWFibGUgbmFtZQ0KICAg
ICAgICAgIGRlcHRoID0gMCAgICAgICAgICAgICAgICAgICAgICAgDQogICAg
ICAgICAgd2hpbGUgZGVwdGggPCAxMDogICAgICAgICAgICAgICAjIExvb3Ag
dGhyb3VnaCB0aGlzIHVudGlsIGl0J3MgZG9uZQ0KICAgICAgICAgICAgICBk
ZXB0aCA9IGRlcHRoICsgMQ0KICAgICAgICAgICAgICBpZiBzdHJpbmcuZmlu
ZCh2YWx1ZSwgIiUoIikgPj0gMDoNCiAgICAgICAgICAgICAgICAgIHRyeToN
CiEgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHZhbHVlICUgZA0KICAg
ICAgICAgICAgICAgICAgZXhjZXB0IEtleUVycm9yLCBrZXk6DQogICAgICAg
ICAgICAgICAgICAgICAgcmFpc2UgSW50ZXJwb2xhdGlvbkVycm9yKGtleSwg
b3B0aW9uLCBzZWN0aW9uLCByYXd2YWwpDQogICAgICAgICAgICAgIGVsc2U6
DQotLS0gMjcwLDI4NSAtLS0tDQogICAgICAgICAgaWYgcmF3Og0KICAgICAg
ICAgICAgICByZXR1cm4gcmF3dmFsDQogIA0KKyAgICAgICAgIHJldHVybiBz
ZWxmLmludGVycG9sYXRlKHJhd3ZhbCwgZCwgb3B0aW9uLCBzZWN0aW9uKQ0K
KyANCisgICAgIGRlZiBpbnRlcnBvbGF0ZShzZWxmLCByYXd2YWwsIGRpY3Rp
b25hcnksIG9wdGlvbiwgc2VjdGlvbik6DQogICAgICAgICAgdmFsdWUgPSBy
YXd2YWwgICAgICAgICAgICAgICAgICAjIE1ha2UgaXQgYSBwcmV0dHkgdmFy
aWFibGUgbmFtZQ0KICAgICAgICAgIGRlcHRoID0gMCAgICAgICAgICAgICAg
ICAgICAgICAgDQogICAgICAgICAgd2hpbGUgZGVwdGggPCAxMDogICAgICAg
ICAgICAgICAjIExvb3AgdGhyb3VnaCB0aGlzIHVudGlsIGl0J3MgZG9uZQ0K
ICAgICAgICAgICAgICBkZXB0aCA9IGRlcHRoICsgMQ0KICAgICAgICAgICAg
ICBpZiBzdHJpbmcuZmluZCh2YWx1ZSwgIiUoIikgPj0gMDoNCiAgICAgICAg
ICAgICAgICAgIHRyeToNCiEgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9
IHZhbHVlICUgZGljdGlvbmFyeQ0KICAgICAgICAgICAgICAgICAgZXhjZXB0
IEtleUVycm9yLCBrZXk6DQogICAgICAgICAgICAgICAgICAgICAgcmFpc2Ug
SW50ZXJwb2xhdGlvbkVycm9yKGtleSwgb3B0aW9uLCBzZWN0aW9uLCByYXd2
YWwpDQogICAgICAgICAgICAgIGVsc2U6DQoqKioqKioqKioqKioqKioNCioq
KiAyOTUsMzAwICoqKioNCi0tLSAzMTMsMzI1IC0tLS0NCiAgICAgICAgICBy
Jyg/UDxoZWFkZXI+Wy1cd18uKiwoKXt9XSspJyAgICAgICAgICMgYSBsb3Qg
b2Ygc3R1ZmYgZm91bmQgYnkgSXZMDQogICAgICAgICAgcidcXScgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAjIF0NCiAgICAgICAgICApDQor
ICAgICBNRVRBQ1JFID0gcmUuY29tcGlsZSgNCisgICAgICAgICByJ1xbJyAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgWw0KKyAgICAgICAg
IHInKD9QPGRpcmVjdGl2ZT5bLVx3XSspJyAgICAgICAgICAgICAgIyBgLScs
IGBfJyBvciBhbnkgYWxwaGFudW0NCisgICAgICAgICByJzonCQkJCSAgICAg
ICMgJzonDQorICAgICAgICAgcicoP1A8cGFyYW0+W15cXV0rKScJCSAgICAg
ICMgYW55dGhpbmcgYnV0IGEgY2xvc2UgXQ0KKyAgICAgICAgIHInXF0nICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIyBdDQorICAgICAgICAg
KQ0KICAgICAgT1BUQ1JFID0gcmUuY29tcGlsZSgNCiAgICAgICAgICByJyg/
UDxvcHRpb24+Wy1cd18uKiwoKXt9XSspJyAgICAgICAgICMgYSBsb3Qgb2Yg
c3R1ZmYgZm91bmQgYnkgSXZMDQogICAgICAgICAgcidbIFx0XSooP1A8dmk+
Wzo9XSlbIFx0XSonICAgICAgICAgICAjIGFueSBudW1iZXIgb2Ygc3BhY2Uv
dGFiLA0KKioqKioqKioqKioqKioqDQoqKiogMzQ5LDM4MiAqKioqDQogICAg
ICAgICAgICAgICAgICAgICAgICAgIHNlbGYuX19zZWN0aW9uc1tzZWN0bmFt
ZV0gPSBjdXJzZWN0DQogICAgICAgICAgICAgICAgICAgICAgIyBTbyBzZWN0
aW9ucyBjYW4ndCBzdGFydCB3aXRoIGEgY29udGludWF0aW9uIGxpbmUNCiAg
ICAgICAgICAgICAgICAgICAgICBvcHRuYW1lID0gTm9uZQ0KISAgICAgICAg
ICAgICAgICAgIyBubyBzZWN0aW9uIGhlYWRlciBpbiB0aGUgZmlsZT8NCiEg
ICAgICAgICAgICAgICAgIGVsaWYgY3Vyc2VjdCBpcyBOb25lOg0KISAgICAg
ICAgICAgICAgICAgICAgIHJhaXNlIE1pc3NpbmdTZWN0aW9uSGVhZGVyRXJy
b3IoZnBuYW1lLCBsaW5lbm8sIGBsaW5lYCkNCiEgICAgICAgICAgICAgICAg
ICMgYW4gb3B0aW9uIGxpbmU/DQogICAgICAgICAgICAgICAgICBlbHNlOg0K
ISAgICAgICAgICAgICAgICAgICAgIG1vID0gc2VsZi5PUFRDUkUubWF0Y2go
bGluZSkNCiEgICAgICAgICAgICAgICAgICAgICBpZiBtbzoNCiEgICAgICAg
ICAgICAgICAgICAgICAgICAgb3B0bmFtZSwgdmksIG9wdHZhbCA9IG1vLmdy
b3VwKCdvcHRpb24nLCAndmknLCAndmFsdWUnKQ0KISAgICAgICAgICAgICAg
ICAgICAgICAgICBvcHRuYW1lID0gc3RyaW5nLmxvd2VyKG9wdG5hbWUpDQoh
ICAgICAgICAgICAgICAgICAgICAgICAgIGlmIHZpIGluICgnPScsICc6Jykg
YW5kICc7JyBpbiBvcHR2YWw6DQohICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAjICc7JyBpcyBhIGNvbW1lbnQgZGVsaW1pdGVyIG9ubHkgaWYgaXQg
Zm9sbG93cw0KISAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIyBhIHNw
YWNpbmcgY2hhcmFjdGVyDQohICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICBwb3MgPSBzdHJpbmcuZmluZChvcHR2YWwsICc7JykNCiEgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgIGlmIHBvcyBhbmQgb3B0dmFsW3Bvcy0xXSBp
biBzdHJpbmcud2hpdGVzcGFjZToNCiEgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICBvcHR2YWwgPSBvcHR2YWxbOnBvc10NCiEgICAgICAgICAg
ICAgICAgICAgICAgICAgb3B0dmFsID0gc3RyaW5nLnN0cmlwKG9wdHZhbCkN
CiEgICAgICAgICAgICAgICAgICAgICAgICAgIyBhbGxvdyBlbXB0eSB2YWx1
ZXMNCiEgICAgICAgICAgICAgICAgICAgICAgICAgaWYgb3B0dmFsID09ICci
Iic6DQohICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHR2YWwgPSAn
Jw0KISAgICAgICAgICAgICAgICAgICAgICAgICBjdXJzZWN0W29wdG5hbWVd
ID0gb3B0dmFsDQogICAgICAgICAgICAgICAgICAgICAgZWxzZToNCiEgICAg
ICAgICAgICAgICAgICAgICAgICAgIyBhIG5vbi1mYXRhbCBwYXJzaW5nIGVy
cm9yIG9jY3VycmVkLiAgc2V0IHVwIHRoZQ0KISAgICAgICAgICAgICAgICAg
ICAgICAgICAjIGV4Y2VwdGlvbiBidXQga2VlcCBnb2luZy4gdGhlIGV4Y2Vw
dGlvbiB3aWxsIGJlDQohICAgICAgICAgICAgICAgICAgICAgICAgICMgcmFp
c2VkIGF0IHRoZSBlbmQgb2YgdGhlIGZpbGUgYW5kIHdpbGwgY29udGFpbiBh
DQohICAgICAgICAgICAgICAgICAgICAgICAgICMgbGlzdCBvZiBhbGwgYm9n
dXMgbGluZXMNCiEgICAgICAgICAgICAgICAgICAgICAgICAgaWYgbm90IGU6
DQohICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlID0gUGFyc2luZ0Vy
cm9yKGZwbmFtZSkNCiEgICAgICAgICAgICAgICAgICAgICAgICAgZS5hcHBl
bmQobGluZW5vLCBgbGluZWApDQogICAgICAgICAgIyBpZiBhbnkgcGFyc2lu
ZyBlcnJvcnMgb2NjdXJyZWQsIHJhaXNlIGFuIGV4Y2VwdGlvbg0KICAgICAg
ICAgIGlmIGU6DQogICAgICAgICAgICAgIHJhaXNlIGUNCi0tLSAzNzQsNDE1
IC0tLS0NCiAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fX3NlY3Rp
b25zW3NlY3RuYW1lXSA9IGN1cnNlY3QNCiAgICAgICAgICAgICAgICAgICAg
ICAjIFNvIHNlY3Rpb25zIGNhbid0IHN0YXJ0IHdpdGggYSBjb250aW51YXRp
b24gbGluZQ0KICAgICAgICAgICAgICAgICAgICAgIG9wdG5hbWUgPSBOb25l
DQohICAgICAgICAgICAgICAgICAjIGEgbWV0YSBkaXJlY3RpdmU/DQogICAg
ICAgICAgICAgICAgICBlbHNlOg0KISAJCSAgICBtbyA9IHNlbGYuTUVUQUNS
RS5tYXRjaChsaW5lKQ0KISAJCSAgICBpZiBtbzoNCiEgCQkgICAgICAgIGRp
cmVjdGl2ZSwgcGFyYW0gPSBtby5ncm91cCgnZGlyZWN0aXZlJywncGFyYW0n
KQ0KISAJCSAgICAgICAgaWYgZGlyZWN0aXZlID09ICJpbmNsdWRlIjoNCiEg
CQkgICAgICAgICAgICBzZWxmLnJlYWQoc2VsZi5pbnRlcnBvbGF0ZShwYXJh
bSxzZWxmLl9fZGVmYXVsdHMsImluY2x1ZGUiLCJtZXRhIGRpcmVjdGl2ZXMi
KSkNCiEgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZToNCiEgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgIHJhaXNlIFVua25vd25EaXJlY3RpdmVF
cnJvcihmcC5uYW1lLCBsaW5lbm8sIGRpcmVjdGl2ZSkNCiEgICAgICAgICAg
ICAgICAgICAgICAjIGFuIG9wdGlvbiBsaW5lPw0KICAgICAgICAgICAgICAg
ICAgICAgIGVsc2U6DQohICAgICAgICAgICAgICAgICAgICAgICAgIGlmIGN1
cnNlY3QgaXMgTm9uZToNCiEgICAgICAgICAgICAgICAgICAgICAgICAgICAg
IHJhaXNlIE1pc3NpbmdTZWN0aW9uSGVhZGVyRXJyb3IoZnAubmFtZSwgbGlu
ZW5vLCBgbGluZWApDQohICAgICAgICAgICAgICAgICAgICAgICAgIG1vID0g
c2VsZi5PUFRDUkUubWF0Y2gobGluZSkNCiEgICAgICAgICAgICAgICAgICAg
ICAgICAgaWYgbW86DQohICAgICAgICAgICAgICAgICAgICAgICAgICAgICBv
cHRuYW1lLCB2aSwgb3B0dmFsID0gbW8uZ3JvdXAoJ29wdGlvbicsICd2aScs
ICd2YWx1ZScpDQohICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRu
YW1lID0gc3RyaW5nLmxvd2VyKG9wdG5hbWUpDQohICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICBpZiB2aSBpbiAoJz0nLCAnOicpIGFuZCAnOycgaW4g
b3B0dmFsOg0KISAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICMg
JzsnIGlzIGEgY29tbWVudCBkZWxpbWl0ZXIgb25seSBpZiBpdCBmb2xsb3dz
DQohICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIyBhIHNwYWNp
bmcgY2hhcmFjdGVyDQohICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgcG9zID0gc3RyaW5nLmZpbmQob3B0dmFsLCAnOycpDQohICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgaWYgcG9zIGFuZCBvcHR2YWxbcG9z
LTFdIGluIHN0cmluZy53aGl0ZXNwYWNlOg0KISAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICBvcHR2YWwgPSBvcHR2YWxbOnBvc10NCiEg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdHZhbCA9IHN0cmluZy5z
dHJpcChvcHR2YWwpDQohICAgICAgICAgICAgICAgICAgICAgICAgICAgICAj
IGFsbG93IGVtcHR5IHZhbHVlcw0KISAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgaWYgb3B0dmFsID09ICciIic6DQohICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgb3B0dmFsID0gJycNCiEgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgIGN1cnNlY3Rbb3B0bmFtZV0gPSBvcHR2YWwNCiEgICAg
ICAgICAgICAgICAgICAgICAgICAgZWxzZToNCiEgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICMgYSBub24tZmF0YWwgcGFyc2luZyBlcnJvciBvY2N1
cnJlZC4gIHNldCB1cCB0aGUNCiEgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICMgZXhjZXB0aW9uIGJ1dCBrZWVwIGdvaW5nLiB0aGUgZXhjZXB0aW9u
IHdpbGwgYmUNCiEgICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgcmFp
c2VkIGF0IHRoZSBlbmQgb2YgdGhlIGZpbGUgYW5kIHdpbGwgY29udGFpbiBh
DQohICAgICAgICAgICAgICAgICAgICAgICAgICAgICAjIGxpc3Qgb2YgYWxs
IGJvZ3VzIGxpbmVzDQohICAgICAgICAgICAgICAgICAgICAgICAgICAgICBp
ZiBub3QgZToNCiEgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBl
ID0gUGFyc2luZ0Vycm9yKGZwbmFtZSkNCiEgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgIGUuYXBwZW5kKGxpbmVubywgYGxpbmVgKQ0KICAgICAgICAg
ICMgaWYgYW55IHBhcnNpbmcgZXJyb3JzIG9jY3VycmVkLCByYWlzZSBhbiBl
eGNlcHRpb24NCiAgICAgICAgICBpZiBlOg0KICAgICAgICAgICAgICByYWlz
ZSBlDQo=
--0-711169532-959463824=:759--