Parser for Unreal Engine config files.
Project description
Unreal INI Parser
Parser for Unreal Engine config files.
How to install
pip install unreal-ini-parser
Usage example
from pathlib import Path
from unreal_ini_parser import IniParser
"""
assume example of ini file:
[MySection]
IsBool = True
Path = path/to/file
JustArray = one
JustArray = two
JustArray = three
"""
def example_print(obj):
print(type(obj).__name__, obj, sep=" | ")
# Create an instance of IniParser
parser = IniParser()
# read ini file
parser.read("example.ini")
# all ini data stored in sections
example_print(parser.sections)
# dict | {'MySection': {'IsBool': ['True'], 'Path': ['path/to/file'], 'JustArray': ['one', 'two', 'three']}}
# all paths that was read
# you can read more files, all data will be added to "sections"
# ini parser also supports @requires keyword to validate required ini files was parsed
example_print(parser.paths)
# set | {WindowsPath('example.ini')}
# get string value of "IsBool" key
is_bool = parser.get_value("MySection", "IsBool")
# same as:
# is_bool = parser.get_value("MySection", "IsBool", str)
example_print(is_bool)
# str | True
# get bool value of "IsBool" key
is_bool = parser.get_value("MySection", "IsBool", bool)
example_print(is_bool)
# bool | True
# get path value of "Path" key
path = parser.get_value("MySection", "Path", Path)
example_print(path)
# Path | path/to/file
# get array of "JustArray" key
# you can use type converters in this case
just_array = parser.get_values("MySection", "JustArray")
example_print(just_array)
# list | ['one', 'two', 'three']
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
unreal_ini_parser-1.0.1.tar.gz
(27.0 kB
view hashes)
Built Distribution
Close
Hashes for unreal_ini_parser-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1459750fa6c54ee5580dd8c5df45a26be9dda16e7ddaf98c010b5a8946730f2c |
|
MD5 | 9ad293e86642575bfb7b3dacade24849 |
|
BLAKE2b-256 | 0eb962d0b4f7c69ed2097144f72535aac5bedfb7800a29f5e2167ad6f922519c |