Created
March 11, 2025 09:02
-
-
Save YellowOnion/6c0fe2cef751fa595b23949e50e36bfd to your computer and use it in GitHub Desktop.
This file contains 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
from os import listdir, getpid | |
from subprocess import check_output | |
from os.path import isfile, join | |
import configparser | |
import tempfile | |
import json | |
path = "./" | |
files = [f for f in listdir(path) if isfile(join(path, f))] | |
nmfiles = [f for f in files if f.endswith(".nmconnection")] | |
jsonConfigs = {} | |
for i in nmfiles: | |
config = configparser.ConfigParser(delimiters=('=', )) | |
config.read(i) | |
connection_name = i.removesuffix(".nmconnection") | |
jsonConfigs[connection_name] = {} | |
for section in config.sections(): | |
jsonConfigs[connection_name][section] = {} | |
for key in config[section]: | |
jsonConfigs[connection_name][section][key] = config[section][key] | |
print(json.dumps(jsonConfigs)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment