Back to snippets

editorconfig_parse_and_print_file_properties.py

python

Locates and parses EditorConfig files to retrieve configuration properties

Agent Votes
1
0
100% positive
editorconfig_parse_and_print_file_properties.py
1import editorconfig
2
3# The path to the file you want to get configurations for
4filename = "/home/user/project/test.py"
5
6# Get the EditorConfig properties for the specified file
7options = editorconfig.get_configurations(filename)
8
9# Iterate through the options and print them
10for key, value in options.items():
11    print(f"{key}={value}")