Skip to main content

UserCfg-Opt-Parser

Black pre-commit GitHub license PyPi versions PyPi downloads


This is a parser for Microsoft Flight Simulator UserCfg.opt files. While the format has some similarities with JSON, I didn't recognize it, nor any AI tools I asked.

Example:

Version 66
{Graphics
	Version 1.1.0
	Preset Custom
	{Texture
		MaxAnisotropy 8
		Quality 1
	}
	{SuperSampling
		SuperSampling 2
	}
}

This package allows you to read and write files in this format. While I have not done extensive testing to see what exactly Microsoft Flight Simulator will and will not accept, the parser tends to be forgiving (CRLF or LF are both accepted, spaces instead of tabs, etc.), the writer matches the format of the file on my computer exactly.

I have found no documentation on the format, so this package is no more than educated guesses. Any undefined behaviors will raise an exception.

Usage

pip install usercfg-opt-parser

A json-like API is provided. File objects must be in binary mode to be able to handle line endings.

import os

import usercfgopt

with open(
    os.path.join(os.environ["APPDATA"], "Microsoft Flight Simulator", "UserCfg.opt"),
    "rb",
) as fp:
    data = usercfgopt.load(fp)

data["Video"]["VSync"] = 1

with open("NewUserCfg.opt", "wb") as fp:
    usercfgopt.dump(data, fp)

FAQs

Why are booleans not allowed?

Because it was unclear if "ON" was truly a boolean, and other 1s and 0s could be integers with more than 2 values.

Why is it so slow?

It's Python and it's a parser written for a single obscure file type. Just getting this working exhausted my motivation.

Should I use this file format?

Please god no. Unless you feel that YAML doesn't have enough ambiguity for your tastes, then I guess sure, go for it.

Development

python -m pip install pipx --upgrade
pipx ensurepath
pipx install poetry
pipx install vscode-task-runner
# (Optionally) Add pre-commit plugin
poetry self add poetry-pre-commit-plugin

Release files for usercfg-opt-parser 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for usercfg-opt-parser 1.0.0
File Size Uploaded
usercfg_opt_parser-1.0.0.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for usercfg-opt-parser 1.0.0
File Interpreter ABI Platform
usercfg_opt_parser-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size:8.9 kB

Release files / usercfg_opt_parser-1.0.0.tar.gz

Download URL usercfg_opt_parser-1.0.0.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
756ad0f6bb37108b9876e2ef9a467b4f213db564833a3ecdee73844afc69068e
BLAKE2b-256 checksum
How to use checksums
83c14020e29a7ca5c60610b758d1e55b1c1208b929a1d073856e94d87e031fcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / usercfg_opt_parser-1.0.0-py3-none-any.whl

Download URL usercfg_opt_parser-1.0.0-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
031eb9e18afdb24ef9c4014f34717fe7fe5a57775df562c8cd2670c673184353
BLAKE2b-256 checksum
How to use checksums
4e09fa3ebc2112b24590bcdd208a76a85559bf216ca809b1fb504126daadd5ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page