k2tools.keyvalues (version 1.00.000 $Rev: 12 $, $Date: 2013-06-28 14:02:35 +0200 (Fr, 28 Jun 2013) $)
index
y:\server\csgo\csgo\addons\source-python\_libs\k2tools\keyvalues.py

Path     addons/source-python/_libs/k2tools/keyvalues.py
Name     Keyvalues
Version  1.00.000
Revision $Rev: 12 $
Author   (C) [#OMEGA] - K2
 
 
IMPORTANT
 
Intended for Valve KeyValue format.
 
See this page for details:
https://developer.valvesoftware.com/wiki/KeyValues_class
 
 
INFO
 
info here
 
 
AGREEMENT
 
See addons/source-python/_libs/k2tools/license.txt
 
Otherwise should be noted that the KeyValues Format is (C) Valve Corporation
 
 
IDEAS/TODO:
 
- Support #include/#base for KeyValuesFile
- Support reading/writing comments

 
Modules
       
re

 
Classes
       
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

 
class ParseError(builtins.Exception)
    
Method resolution order:
ParseError
builtins.Exception
builtins.BaseException
builtins.object

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Methods inherited from builtins.Exception:
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature

Data and other attributes inherited from builtins.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from builtins.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)
with_traceback(...)
Exception.with_traceback(tb) --
set self.__traceback__ to tb and return self.

Data descriptors inherited from builtins.BaseException:
__cause__
exception cause
__context__
exception context
__dict__
__suppress_context__
__traceback__
args

 
Data
        __all__ = ['ParseError', 'KeyValues', 'KeyValuesParser', 'KeyValuesFile']

 
Author
        [#OMEGA] - K2