Dave Cinege Git Repo thesaurus / cce7589 thesauruscfg_sample.cfg
cce7589

Tree @cce7589 (Download .tar.gz)

thesauruscfg_sample.cfg @cce7589raw · history · blame

"""
thesauruscfg_sample.cfg
	Copyright (c) 2019 Dave Cinege
	Licensed under the Apache License, Version 2.0

VERSION = 20191113

This is the sample configuration file and specification document
for Python ThesaurusCfg, which utilizes the Thesaurus mapping datatype.

ThesaurusCfg file format is generally very similar in structure to the INI
file format used by Python ConfigParser, with some major differences.

Multi line Comments (doc strings) are supported, using double or single
triple-quotes. Triple quotes should start at the begining of a line,
but may end anywhere.

ThesaurusCfg is designed to work with dot seperated (Keypath) configuration
trees (nested ThesaurusCfg objects). 'Sections' may be used as a
keypath prefix for easier human parsing.

For example:
	a.b.c.v0 = 0
	a.b.c.v1 = 0
	a.b.c.v2 = 0

Can also be writen as:
	[a.b.c]
	v0 = 0
	v1 = 0
	v2 = 0

To reset the keypath prefix use empty brackets on a line:
	[]

Keypath's and Sections must start at the beginng of a line

Lines take the form of:
	keypath(optional_coercion_method)=value
	
Arbitrary whitespace may exist between any tokens:
	keypath  ( optional_coercion_method )  =  value

Value coercion methods are defined in ThesaurusCfg itself and
not explained here. 

Since the keypath is split on '.' it is a good idea to avoid dots in
key names. However if you must use dots (or other bad idea characters,
like whitespace) in a key name is it supported by quoting.

For example:	
	[lab.domain.'someplace.net']
	admin.'joe doe'.phone = 867-5309
	admin.'joe doe'.email = joe@doe.org

configparser._value_lstrip=False
The parser strips at most 1 whitespace charter to the right of the value
delimiter.
For example:
	a = hello	== 'hello'
	a=hello		== 'hello'
	a =  hello	== ' hello'

configparser._value_rstrip_comment=True
Comments on the right side of single line keypath/value will be
stripped prior to the possible stripping of any whitespace.

	a = hello	# Lets make a equal hello
	
"""
# Single line comment


# Simple key values using coercion methods
abc		(static_int)	= 123
xyz		(int)		= 678
myitemlist	(str_list)	= "Item 1's" "'Item_2'" "Item 3" "Item_4"
mybool		(str_to_bool)	= yes

# Keypath and value
a.bc		(static_int)	= 456
program.name	= thesauruscfg_sample.py

# keypath and multi-line value
program.description:
	This program is to test the functionality of the ThesaurusCfg
	Python module. We prefer ':\n' value delimiters for multi-line.

# Using a keypath prefix 'section'. 'program.name' and
# 'program.description' defined above will already be here.
[program]
version		= 3.0
release		= 20191112
author		= Dave Cinege
licence		= Apache 2.0

# Reset (clear) the keypath prefix 'section'. While you can do this,
# it's of course cleaner to keep the root level keys all together.
# Remember that Thesaurus is ORDERED so this will define after the above
# keypaths, and not right after the orginal root level keys.
[]
abc_2		(static_int)	= 1234

# We will apply these defaults to the below gateways using Thesaurus.mesh(),
# so that every gateway always has the default values, without having to
# list them multiple times. 
[defaults.gateways]
table			= 10
ifname 			= eth0
router 		(ipv4)	= 192.168.0.1
dns 		(ipv4)	= 9.9.9.9
inkbps 		(int)	= 99000
outkbps 	(int)	= 99000

[networks.nyc9234.gateways]
router			= 100.64.1.1

[networks.mia00234.gateways]
ifname			= eth2
router			= 100.65.1.1

[networks.buda793.gateways]
router			= 100.66.2.1


[hosts]
'mercury.mydom.org'.ip	= 192.168.1.1
'saturn.mydom.org'.ip	= 192.168.1.2
'venus.mydom.org'.ip	= 192.168.1.3

[hosts.'earth.mydom.org']
ip			= 192.168.1.10
router			= 192.168.1.254
notes:
	Primary host to access the universe.
	Replaced keyboard 20170104



# NOTE: 20191112 NOT YET IMPLEMENTED
## Sectional inheritance: defaults.gateways always merged first
#[networks.buda793.gateways:defaults.gateways]
#router			= 100.66.2.1