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.
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)
Because it was unclear if "ON" was truly a boolean, and other 1s and 0s could be integers with more than 2 values.
It's Python and it's a parser written for a single obscure file type. Just getting this working exhausted my motivation.
Please god no. Unless you feel that YAML doesn't have enough ambiguity for your tastes, then I guess sure, go for it.
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