Skip to main content

ConfigParser (in text) created for read/edit/write Unreal Engine Config files

Project description

UnrealConfigParser Utility

This project provides a Python-based utility for handling configuration files in Unreal Engine workflows or other INI-style configurations. It offers a range of features to read, write, and modify configuration files programmatically.

Features

  • Read and Write Configuration Files: Seamlessly read and write configuration data.
  • Section and Key Management: Add, remove, and modify keys in specific sections.
  • Value Matching and Replacement: Modify values based on substrings or specific criteria.
  • Comment/Uncomment Keys: Enable or disable keys in configuration files.

Installation

pip install ueconfigparser

Ensure you have Python 2.7 or later installed.

Usage

Here are some examples of how to use the utility.

Example 1: Reading Configuration Files

from ueconfigparser import UnrealConfigParser

# Initialize the parser
parser = UnrealConfigParser()

# Read a configuration file
parser.read('config.ini')

# Display contents
parser.display()

Example 2: Writing to Configuration Files

from ueconfigparser import UnrealConfigParser

# Initialize the parser
parser = UnrealConfigParser()

# Read and modify the configuration file
parser.read('config.ini')
parser.add_key('General', 'NewKey', 'NewValue')

# Write changes to a new file
parser.write('updated_config.ini')

Example 3: Modifying a Key Value

from ueconfigparser import UnrealConfigParser

# Initialize the parser
parser = UnrealConfigParser()

# Read the configuration file
parser.read('config.ini')

# set a key's value
parser.set('General', 'ExistingKey', 'UpdatedValue')

# Save the changes
parser.write('updated_config.ini')

Example 4: Commenting and Uncommenting Keys

from ueconfigparser import UnrealConfigParser

# Initialize the parser
parser = UnrealConfigParser()

# Read the configuration file
parser.read('config.ini')

# Comment a key
parser.comment_key('General', 'KeyToDisable')

# Uncomment a key
parser.uncomment_key('General', 'KeyToEnable')

# Save the changes
parser.write('updated_config.ini')

Example 5: Replace Substring in a Section

from ueconfigparser import UnrealConfigParser

# Initialize the parser
parser = UnrealConfigParser()

# Read the configuration file
parser.read('config.ini')

# Replace a substring in a section
parser.replace_substring_in_section('General', 'OldSubstring', 'NewSubstring')

# Save the changes
parser.write('updated_config.ini')

API Reference

UnrealConfigParser

Methods:

  • read(file_path: str)

    • Reads a configuration file.
    • Parameters: file_path - Path to the file to read.
  • write(output_path: str, newline_option=None)

    • Writes the modified configuration to a file.
    • Parameters:
      • output_path - Path to save the file.
      • newline_option - Newline character to use (default: None).
  • add_key(section: str, key: str, value: str)

    • Adds a new key-value pair to a section.
  • remove_key(section: str, key: str)

    • Removes a key from a section.
  • set(section: str, key: str, new_value: str, spacing=False)

    • Modifies the value of a key in a section.
  • comment_key(section: str, key: str)

    • Disables a key by commenting it out.
  • uncomment_key(section: str, key: str)

    • Enables a key by uncommenting it.
  • set_value_by_string_serach_in_section(section: str, match_substring: str, new_value: str)

    • Updates any key's value in a section if it matches a substring.
  • set_value_by_string_search_in_value(section: str, key: str, match_substring: str, new_value: str)

    • Updates a key's value if it matches a specific substring.
  • replace_value_by_string_search_in_value(section: str, key: str, match_substring: str, new_substring: str)

    • Replaces a substring in the value of a specific key.
  • replace_value_by_string_search_in_section(section: str, match_substring: str, new_substring: str)

    • Replaces substrings in the values of all keys within a section.
  • comment_key_by_string_search_in_value(section: str, key: str, match_substring: str)

    • Comments out a key if its value matches a specific substring.
  • uncomment_key_by_string_search_in_value(section: str, key: str, match_substring: str)

    • Uncomments a key if its value matches a specific substring.
  • comment_key_by_string_search_in_section(section: str, match_substring: str)

    • Comments out keys in a section if their values match a substring.
  • uncomment_key_by_section_search(section: str, match_substring: str)

    • Uncomments keys in a section if their values match a substring.
  • display()

    • Prints the current configuration to the console.

Author

This project was created by WooJin Kim.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributions

Contributions are welcome! Please submit issues or pull requests to improve functionality or documentation.

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

ueconfigparser-1.1.4.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ueconfigparser-1.1.4-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file ueconfigparser-1.1.4.tar.gz.

File metadata

  • Download URL: ueconfigparser-1.1.4.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.13

File hashes

Hashes for ueconfigparser-1.1.4.tar.gz
Algorithm Hash digest
SHA256 64fd139bb5517f330110d65375a4feccbfcebd83ce7cc14c6f51b3346e6fcf2a
MD5 6c9e049ffbf7c3480ee3c96e549e378f
BLAKE2b-256 a0ef3583aed1dbd053dbd411e4bf9fdad5adddf6f9692be74aa8530f49b0702c

See more details on using hashes here.

File details

Details for the file ueconfigparser-1.1.4-py3-none-any.whl.

File metadata

  • Download URL: ueconfigparser-1.1.4-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.13

File hashes

Hashes for ueconfigparser-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f028c61a70c82e919a12dcd4780d2625ebd7bb76c02eaf4f5808e0b2cdcc5dc8
MD5 d827fc616bef900c4e1336638897f347
BLAKE2b-256 adf4bacb0171bc667c329d2280326fa3a4153a2e9b8c110638f0c9ee6f852cc0

See more details on using hashes here.

Supported by

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