Created
April 24, 2025 13:43
-
-
Save SpiffGreen/d24804b6284ff464aae258e86681c4b9 to your computer and use it in GitHub Desktop.
Code to turn python with braces to proper python
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
import sys | |
# Coupled with this extension | |
# https://marketplace.visualstudio.com/items?itemName=emeraldwalk.RunOnSave | |
# And VS Code setting after extension install | |
# "emeraldwalk.runonsave": { | |
# "commands": [ | |
# { | |
# "match": ".*\\.py$", | |
# "cmd": "python3 clean_braces.py ${file}" | |
# } | |
# ] | |
# } | |
path = sys.argv[1] | |
with open(path, 'r+') as f: | |
code = f.read() | |
# Remove standalone curly braces | |
code = code.replace('{', ':').replace('}', '') | |
f.seek(0) | |
f.write(code) | |
f.truncate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment