API¶
Methods¶
static | useFastDict([var]) |
static | setIndentation([var]) |
static | setSpacing([var]) |
static | setCondensed([var]) |
static | setMaxTokenLength([var]) |
static | read(f) |
static | reads(s) |
static | formatData(data) |
static | writeData(f, data) |
load(f) | |
loads(data) | |
getData() | |
setData(data) | |
find(path) | |
edit(path, value) | |
findMany(paths) | |
editMany(paths) | |
write_file(f) | |
toString() |
Class Details¶
- class PyVDF(data=None, infile=None)¶
Parse VDFs and Valve KeyValue Files
- static useFastDict(var=True)¶
Use the faster built-in dict class, or the slower, OrderedDict class
Parameters: var (bool) – Use fast dict or not.
- static setIndentation(var='t')¶
Set the indentation of the output
Parameters: var (str) – The indentation to use
- static setSpacing(var='tt')¶
Set the output spacing
Parameters: var (str) – The characters to use for spacing
- static setCondensed(var=False)¶
Set condensed output
Parameters: var (bool) – Use condensed output or not
- static setMaxTokenLength(var=1024)¶
Set the maxmimum token length that can be read.
Parameters: var (int) – Number of characters allowed in a token
- static read(f)¶
Parse a String and return the data
Parameters: f (file/str) – The file to read Returns: A dictionary object containing the parsed data from f Raises: SyntaxError - An error occured reading the data.
- static reads(s)¶
Parse a String and return the data
Parameters: s (str) – The string to read Returns: A dict object containing the data from s Raises: SyntaxError - An error occured reading the data.
- static formatData(data)¶
Format a dictionary object to look like a VDF file
Parameters: data (dict) – Data Returns: A vdf string representation of data
- static writeData(f, data)¶
Write a dictionary object to a file
Parameters: - f (file/string) – The file to write to
- data (dict) – The data to write to the file
- load(f)¶
Parse a file and return a dictionary object
Parameters: f (file/string) – The file to read Returns: A dict object containing the data from s Raises: SyntaxError - An error occured reading the data
- loads(data)¶
Parse a string and return a dictionary object
Parameters: data (str) – The data to read Returns: A dict object containing the data from s Raises: SyntaxError - An error occured reading the data.
- getData()¶
Get the instance data
- setData(data)¶
Set the data of the instance
Parameters: data (dict) – The data
- find(path)¶
Find a value
Parameters: path (str) – The Key path to search for Returns: The found value or an empty string if not found.
- edit(path, value)¶
Edit a key value
Parameters: - path (str) – The path key for the value
- value (str) – The value to be set
- findMany(paths)¶
Find multiple values
Parameters: paths (str) – A list of path strings Returns: The found value or an empty string if not found.
- editMany(paths)¶
Edit multiple key values
Parameters: path (tuple) – A list or tupple of lists or tupples.
- write_file(f)¶
write the instance data to a file
Parameters: f (str) – The file to write to
- toString()¶
return the instance data as a vdf string
Returns: A string of the instance data, in a vdf format Return type: str