Implements basic BOM/Codec detection, PEP compliance and style guide pass, Python3 modernisation #2
Open
lili7h wants to merge 1 commit intogorgitko:masterfrom
Open
Implements basic BOM/Codec detection, PEP compliance and style guide pass, Python3 modernisation #2lili7h wants to merge 1 commit intogorgitko:masterfrom
lili7h wants to merge 1 commit intogorgitko:masterfrom
Conversation
gorgitko
approved these changes
Sep 8, 2024
Owner
gorgitko
left a comment
There was a problem hiding this comment.
Hey, great job, and thanks so much for keeping this project alive with a modern touch! 😎
I am not sure if Python 2 support is worth the extra work. Let's focus on Py3.
One nit: unify quotes. Let's use either " or '
I don’t have any plans for this repo moving forward, and you clearly know what you're doing. So feel free to take it over! 👨🍼
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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=Trueflag 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.