Skip to content

Instantly share code, notes, and snippets.

@kastoestoramadus
Last active February 27, 2025 11:19
Show Gist options
  • Save kastoestoramadus/c2231678277658cba0bcfca84106c952 to your computer and use it in GitHub Desktop.
Save kastoestoramadus/c2231678277658cba0bcfca84106c952 to your computer and use it in GitHub Desktop.
python script
import sys
import ddpyhocon
def format_hocon(input_file, output_file):
with open(input_file, 'r') as infile:
# Parse the HOCON file into a Python dictionary
config = ddpyhocon.ConfigFactory.parse_file(infile)
with open(output_file, 'w') as outfile:
# Write the formatted HOCON file
config.save(outfile, pretty=True) # pretty=True enables pretty printing
if __name__ == "__main__":
# You can pass the input and output file paths as arguments
input_path = sys.argv[1]
output_path = sys.argv[2]
format_hocon(input_path, output_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment