Skip to main content

Config parser for UDK .ini files.

Project description

udk_configparser

Like CPython standard configparser but adjusted for UDK config files.

Installation

pip install udk_configparser

Example usage

Setting a single value

from udk_configparser import UDKConfigParser

cg = UDKConfigParser()

cg.read("Engine.ini")
cg["Section"]["Key"] = "NewValue"

Setting a multi-value field and writing the file

# Multi-value example.
pkg_name = "MyPackage"
edit_packages = cg["UnrealEd.EditorEngine"].getlist("+EditPackages")
if pkg_name not in edit_packages:
    edit_packages.append(pkg_name)
    # Currently, setting multi-value data requires manually 
    # joining the data to ensure it is written correctly.
    cg["UnrealEd.EditorEngine"]["+EditPackages"] = "\n".join(edit_packages)

with open("Engine.ini", "w") as config_file:
    cg.write(config_file, space_around_delimiters=False)

# Engine.ini before writing:
#  [UnrealEd.EditorEngine]
#  +EditPackages=UTGame
#  +EditPackages=UTGameContent

# After:
#  [UnrealEd.EditorEngine]
#  +EditPackages=UTGame
#  +EditPackages=UTGameContent
#  +EditPackages=MyPackage

Known issues

  • Comments get removed during writes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

udk_configparser-1.1.1.tar.gz (7.9 kB view hashes)

Uploaded Source

Built Distribution

udk_configparser-1.1.1-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page