Parse a coil string.
See Parser for possible keyword arguments.
| Parameters: | file_name (str) – String containing data to parse. |
|---|---|
| Returns: | The root object. |
| Return type: | Struct |
Open and parse a coil file.
See Parser for possible keyword arguments.
| Parameters: | file_name (str) – Name of file to parse. |
|---|---|
| Returns: | The root object. |
| Return type: | Struct |
Bases: object
The standard coil parser.
| Parameters: |
|
|---|
Get the raw unexpanded prototype, you probably don’t want this.
| Return type: | StructPrototype |
|---|
Bases: coil.tokenizer.Location, UserDict.DictMixin
A dict-like object for use in trees.
| Parameters: |
|
|---|
Signal set() to preserve location data for key
Get a value from any Struct in the tree.
| Parameters: |
|
|---|---|
| Returns: | The fetched item or the value of default. |
Set a value in any Struct in the tree.
| Parameters: |
|
|---|
Recursively merge a coil Struct tree.
This is similar to update() except that it will update the entire subtree rather than just this object.
Get an ordered list of keys.
Alias for keys().
Only for compatibility with Coil <= 0.2.2.
True if key is in this Struct
Iterate over the ordered list of (key, value) pairs.
Sort in place. By default items are sorted by key.
Alternate sort methods may be provided by giving a custom cmp method. The arguments to cmp will be (key, value) pairs.
Expand all Link and sub-string variables in this and, if recursion is enabled, all child Struct objects. This is normally called during parsing but may be useful if more control is required.
This method modifies the tree!
| Parameters: |
|
|---|
Fetch and expand an item at the given path. All Link and sub-string variables will be followed in the process. This method is a no-op if value is a Struct, use the Struct.expand() method instead.
This method does not make any changes to the tree.
| Parameters: |
|
|---|
Use this Struct to expand the given value. All Link and sub-string variables will be followed in the process. This method is a no-op if value is a Struct, use the expand() method instead.
This method does not make any changes to the tree.
| Parameters: |
|
|---|
Find a set of all keys that have not been expanded. This is generally only useful if expand() was run with the ignore_missing parameter was set to see got missed.
Normally only the short key name is given as it would be provided in defaults or ignore_missing parameters for the various expansion methods. Set absolute=True to return the full path for each key instead.
| Parameters: |
|
|---|---|
| Returns: | unexpanded keys |
| Return type: | set |
Recursively copy this Struct
Get the absolute path of this Struct if path is None, otherwise the relative path from this Struct to the given path.
Convert this Struct tree to the coil text format.
Note that if any value is a unicode string then this will return a unicode object rather than a str.
| Parameters: |
|
|---|
Alternate version of Struct.string() that generates a flat key: value list rather than a Struct tree. This is equally as valid as the standard format and sometimes is easier to read.
| Parameters: |
|
|---|---|
| Type : | string |
Check if the given key is valid.
| Return type: | bool |
|---|
Check if the given path is valid.
| Return type: | bool |
|---|
Bases: exceptions.Exception
Generic error for Coil
Update the parser location for this exception. This is useful for properly tagging StructError instances that are raised during parse time.
Bases: coil.errors.CoilError
Generic error for coil.struct.Struct objects, used by various Key errors.
Bases: coil.errors.StructError, exceptions.KeyError
The given key was not found
Bases: coil.errors.StructError, exceptions.TypeError
The given key was not a string
Bases: coil.errors.StructError, exceptions.ValueError
The given key contained invalid characters
Bases: coil.errors.StructError
The given item in a path was not the correct type
Bases: coil.errors.CoilError
General error during parsing
Bases: coil.errors.CoilParseError
Invalid unicode string