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

Fix json_cleaner #22

Merged
merged 1 commit into from
Dec 19, 2021
Merged

Fix json_cleaner #22

merged 1 commit into from
Dec 19, 2021

Conversation

cda94581
Copy link
Contributor

A few changes to the json_cleaner.py file to ensure it works properly.
I noticed that #21 also exists to do something similar using Nim.

  1. for file in glob.glob("**/*.json"): -> for file in glob.glob("**/*.json", recursive=True):
    • While debugging other areas of the file, I noticed the filter only targets top-level files, such as BP/manifest.json, RP/sounds.json, etc. Adding recursive=True finds all files in the subfolders as well.
  2. json_data = get_json_from_file(fh) -> json_data = get_json_from_file(fh.read())
    • Added fh.read() to send a string as arguments, mainly to be used in the except section of the function.
  3. json_data = json.load(fh) -> return json.loads(fh)
    • Using json.loads instead of json.load, because the argument is now a string instead of a file.
    • json_data variable declaration was unused, so that was removed.
    • If the try condition passes, without the return statement, the python object in which to convert to json is None or null. Hence, the files are written with null replacing everything. The return statement ensures a python object is returned.
  4. for line in fh: -> for line in fh.splitlines():
    • Using .splitlines() splits the string into each line, allowing for the following lines to function.

@SirLich SirLich merged commit 5d1385c into Bedrock-OSS:master Dec 19, 2021
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

Successfully merging this pull request may close these issues.

2 participants