1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-01-09 21:17:52 +03:00

Add create_ini_file function

This commit is contained in:
Valery Sinelnikov 2023-07-11 12:06:31 +04:00
parent 7e225c837a
commit fc810c3362

View File

@ -179,3 +179,21 @@ def touch_file(filename):
path = Path(filename)
path.parent.mkdir(parents=True, exist_ok=True)
path.touch()
def create_ini_file(filename, data):
"""
Create an ini-file based on a dictionary of dictionaries.
Args:
data (dict): The dictionary of dictionaries containing the data for the ini-file.
filename (str): The filename to save the ini-file.
Returns:
None
Raises:
None
"""
with open(filename, 'w') as file:
for section, section_data in data.items():
file.write(f"[{section}]\n")
for key, value in section_data.items():
file.write(f"{key} = {value}\n")
file.write("\n")