Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adbancroft/tunerstudioiniparser
TsIniParser - a TunerStudio INI parser
https://github.com/adbancroft/tunerstudioiniparser
ini parser tunerstudio
Last synced: about 1 month ago
JSON representation
TsIniParser - a TunerStudio INI parser
- Host: GitHub
- URL: https://github.com/adbancroft/tunerstudioiniparser
- Owner: adbancroft
- Created: 2021-08-07T18:46:51.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-09-24T15:43:38.000Z (over 1 year ago)
- Last Synced: 2024-10-16T06:34:19.890Z (3 months ago)
- Topics: ini, parser, tunerstudio
- Language: Python
- Homepage:
- Size: 3.42 MB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# A Python parser for TunerStudio INI files
Example:import sys
from ts_ini_parser import TsIniParser, DataClassTransformer
parser = TsIniParser()
parser.define('LAMBDA', True)
parser.define('ALPHA_N', True)
with open(sys.argv[1], 'r') as file:
tree = parser.parse(file)
# tree will contain the parsed INI file as a Lark Tree
# object with any #if preprocessing directives applied
#
# The Lark tree conatins a lot of detail that most consumers
# won't need. It's main appeal is that the tree elements can
# be tied back to the file lines & columns
#
# Apply a predefined transform to convert the tree into
# an idiomatic Python object tree
dataclass = DataClassTransformer().transform(tree)injBatRates = dataclass['Constants'][6]['injBatRates']
print(injBatRates.dim1d)Note that this parser is less tolerant of format issues than TunerStudio:
- Key-value pairs: the value must be comma delimited (TunerStudio
tolerates spaces)
- There must be a blank line at the end
- Expression markers ("{", "}") and parentheses ("(", ")") must be balanced
- All identifiers must be Java/C/C++ [identifers](https://docs.microsoft.com/en-us/cpp/c-language/c-identifiers?view=msvc-160) (no spaces, quotes etc.)