Rivista/rivista/utilities.py
Schimon Jehudah, Adv. 5fd6a6c710 Automate installation process;
Add command line prompt to set configurations;
Update document README.
2024-11-20 17:21:26 +02:00

22 lines
471 B
Python

#!/usr/bin/python
# -*- coding: utf-8 -*-
import tomli_w
try:
import tomllib
except:
import tomli as tomllib
class Toml:
def open_file_toml(filename: str) -> dict:
with open(filename, mode="rb") as fn:
data = tomllib.load(fn)
return data
def save_to_toml(filename: str, data: dict) -> None:
with open(filename, 'w') as fn:
data_as_string = tomli_w.dumps(data)
fn.write(data_as_string)