Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRY UKVS converter and leverage standard parser #9

Open
ibnesayeed opened this issue Oct 27, 2021 · 1 comment
Open

DRY UKVS converter and leverage standard parser #9

ibnesayeed opened this issue Oct 27, 2021 · 1 comment

Comments

@ibnesayeed
Copy link
Member

Currently, ukvsconvert.py has some duplicate code in various serialization functions, which can benefit from some DRYing (Don't Repeat Yourself).

More importantly, it parses UKVS files with a very specific order and spacing in mind, which makes the parser brittle and defeats the purpose of JSON block. After splitting the first two columns out the remaining JSON part of the line can simply be parsed using standard json.loads() function.

Moreover, a template system can be used to serialize the output in various formats. This is not necessary, but will make the code more maintainable in the long run. In fact, JSON serialization does not even need a custom template, it can simply be done using json.dumps() function (the output can be customized to have certain indentation, spacing, line breaks, or sorting of keys).

@esavaria
Copy link
Contributor

I agree this is a much more robust approach to generating the json output. As more features are added templates will help with the efficiency as well.

Thanks,
Evan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants