valve-keyvalues-python icon indicating copy to clipboard operation
valve-keyvalues-python copied to clipboard

Implements basic BOM/Codec detection, PEP compliance and style guide pass, Python3 modernisation

Open lili7h opened this issue 1 year ago • 0 comments

I guess im coming back to this old project again haha.

I noted that if you accidentally specified the wrong codec, Python would not appropriately strip the BOM char out of the file, which would result in the regex to identify the first Key failing to match because the line didn't start with a ". 99% of the time, you will be fine just using the default UTF8, but sometimes Valve throws a curveball at you with a Source 1 UTF-16 encoded file.

The current implementation will pick up a BOM char if it exists, and convert that to the appropriate encoding string, then will drop a warning about overriding the specified encoding with the new one. You can override this by using the ignore_bom=True flag in class init.

I also ran some styling sweeps over the file to make it a little more happy with the PEP style guides, and removed references to Py2 functions. If you want to keep Py2 support, then I can go back and do some proper Py2/3 inter-support with the futures/futurize package.

Happy to take comments/feedback on this and make changes as needed.

lili7h avatar Sep 08 '24 04:09 lili7h