| | |
- builtins.Exception(builtins.BaseException)
-
- ParseError
- builtins.object
-
- KeyValues
-
- KeyValuesFile
- KeyValuesParser
class KeyValues(builtins.object) |
| |
The most basic KeyValues class which acts as KeyValue representation in
python.
It works similar to a dictionary in python, however, all keys are ordered. |
| |
Methods defined here:
- __contains__(self, key)
- __delitem__(self, key)
- __eq__(self, obj)
- # Basic Methods
- __getitem__(self, key)
- # Container type emulation
- __init__(self, parent=None)
- @parent - parent KeyValues object (if present)
- __iter__(self)
- # Iterator
- __ne__(self, obj)
- __next__(self)
- __repr__(self)
- # Representation
- __setitem__(self, key, value)
- __str__(self)
- copy(self)
- Provides a superfical independant copy of this KeyValue object.
Keys that do have a KeyValues object as value will still point to the
same object in memory (which means, changing such an KeyValue will
affect both the copy and the original object).
- deep_copy(self)
- Provides a deep independent copy of this KeyValue object.
The difference to .copy() is that values that are KeyValue objects
will be recreated instead of staying the same object.
However, objects of other types, will still have the same problem,
though "offically" you should not assign any non basic types as value.
- get_depth(self)
- Returns the current depth of this KeyValues object in a Key/Subkey
hirarchy.
0 is top-level.
- keys(self)
- Returns an ordered list of keys.
- merge(self, obj, override=True)
- Merges this KeyValues object with another KeyValues object.
@obj - KeyValues object to merge with
@override - Whether to override Key/Value pairs if they exist in the
other object.
True will use the new value from the merging object
False will use the original value from this object
- values(self)
- Returns an ordered list of values.
- walk(self, depth=-1)
- Walks though this object and returns key-value pairs
@depth - If known, the depth can be specified here (Default: -1)
If set to -1, the depth will be automatically determined
Returns a list containing the following tuple:
(KeyValues object, key, value, depth)
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes defined here:
- __hash__ = None
|
class KeyValuesFile(KeyValues) |
| |
The KeyValuesFile class handles using KeyValues with file input/output. |
| |
- Method resolution order:
- KeyValuesFile
- KeyValues
- builtins.object
Methods defined here:
- __init__(self)
- load(self, file=None, newline=None)
- Loads the specified file and parses the KeyValues data contained
within.
@file - Path to the KeyValue file
@newline - If None let python determine the newline type
- write(self, file=None)
- Writes the current data stored in this object to the specified file in
KeyValues format. Please note that this will override any existing
file.
@file - Path to the KeyValue file
Methods inherited from KeyValues:
- __contains__(self, key)
- __delitem__(self, key)
- __eq__(self, obj)
- # Basic Methods
- __getitem__(self, key)
- # Container type emulation
- __iter__(self)
- # Iterator
- __ne__(self, obj)
- __next__(self)
- __repr__(self)
- # Representation
- __setitem__(self, key, value)
- __str__(self)
- copy(self)
- Provides a superfical independant copy of this KeyValue object.
Keys that do have a KeyValues object as value will still point to the
same object in memory (which means, changing such an KeyValue will
affect both the copy and the original object).
- deep_copy(self)
- Provides a deep independent copy of this KeyValue object.
The difference to .copy() is that values that are KeyValue objects
will be recreated instead of staying the same object.
However, objects of other types, will still have the same problem,
though "offically" you should not assign any non basic types as value.
- get_depth(self)
- Returns the current depth of this KeyValues object in a Key/Subkey
hirarchy.
0 is top-level.
- keys(self)
- Returns an ordered list of keys.
- merge(self, obj, override=True)
- Merges this KeyValues object with another KeyValues object.
@obj - KeyValues object to merge with
@override - Whether to override Key/Value pairs if they exist in the
other object.
True will use the new value from the merging object
False will use the original value from this object
- values(self)
- Returns an ordered list of values.
- walk(self, depth=-1)
- Walks though this object and returns key-value pairs
@depth - If known, the depth can be specified here (Default: -1)
If set to -1, the depth will be automatically determined
Returns a list containing the following tuple:
(KeyValues object, key, value, depth)
Data descriptors inherited from KeyValues:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes inherited from KeyValues:
- __hash__ = None
|
class KeyValuesParser(KeyValues) |
| |
This class adds parsing capbilities on top of the base KeyValues class. |
| |
- Method resolution order:
- KeyValuesParser
- KeyValues
- builtins.object
Methods defined here:
- __init__(self, data='', newline=r'\n')
- Creates a new KeyValuesParser object from the provided data.
@data - A string containing data to parse with the KeyValues syntax
@newline - Newline-style used in the data (Default:
)
Operating Systems use these by default:
- Linux :
- MAC :
- Windows:
Methods inherited from KeyValues:
- __contains__(self, key)
- __delitem__(self, key)
- __eq__(self, obj)
- # Basic Methods
- __getitem__(self, key)
- # Container type emulation
- __iter__(self)
- # Iterator
- __ne__(self, obj)
- __next__(self)
- __repr__(self)
- # Representation
- __setitem__(self, key, value)
- __str__(self)
- copy(self)
- Provides a superfical independant copy of this KeyValue object.
Keys that do have a KeyValues object as value will still point to the
same object in memory (which means, changing such an KeyValue will
affect both the copy and the original object).
- deep_copy(self)
- Provides a deep independent copy of this KeyValue object.
The difference to .copy() is that values that are KeyValue objects
will be recreated instead of staying the same object.
However, objects of other types, will still have the same problem,
though "offically" you should not assign any non basic types as value.
- get_depth(self)
- Returns the current depth of this KeyValues object in a Key/Subkey
hirarchy.
0 is top-level.
- keys(self)
- Returns an ordered list of keys.
- merge(self, obj, override=True)
- Merges this KeyValues object with another KeyValues object.
@obj - KeyValues object to merge with
@override - Whether to override Key/Value pairs if they exist in the
other object.
True will use the new value from the merging object
False will use the original value from this object
- values(self)
- Returns an ordered list of values.
- walk(self, depth=-1)
- Walks though this object and returns key-value pairs
@depth - If known, the depth can be specified here (Default: -1)
If set to -1, the depth will be automatically determined
Returns a list containing the following tuple:
(KeyValues object, key, value, depth)
Data descriptors inherited from KeyValues:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes inherited from KeyValues:
- __hash__ = None
|
|