SCF aims to create a very simple format which is ideal for config usage. It is separated into "Sections", "Keys" and "Values".
Each SCF file must have at least one section and all extra key->values must be within a section.
# Comment
<test.scf>
{section1}
database = "hello"
hello = true
list = [
[10, 10],
"test", "test", "test"
]
test = {"test": 10}
x = 10
#
Comment{x}
Section<file.scf>
Importkey = value
true/false
orTrue/False
-> Bool10
-> Integer10.3
-> Float"string"
or'string'
-> String[1, 2]
-> List{"a": 10}
-> Dictionary(1, 2)
-> Tuple
The config will be returned as a Python dictionary.
SCF can be parsed from a file or from a string.
test.scf
{section1}
database = "hello"
hello = true
list = [
[10, 10],
"test", "test", "test"
]
test = {"test": 10}
x = 10
Python
>>> config = SCF.read("test.scf")
>>> config
{'section1': {'database': 'hello', 'hello': True, 'list': [[10, 10], 'test', 'test', 'test'], 'test': {'test': 10}, 'x': 10}}
Python
>>> config_string = """
{section1}
database = "hello"
hello = true
list = [
[10, 10],
"test", "test", "test"
]
test = {"test": 10}
x = 10
"""
>>> config = SCF.parse(config_string)
>>> config
{'section1': {'database': 'hello', 'hello': True, 'list': [[10, 10], 'test', 'test', 'test'], 'test': {'test': 10}, 'x': 10}}
Both read
and parse
have two keyword arguments error_report
and strict
. error_report
will print warnings on duplicate keys whereas strict
will raise an exception.