- Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathtoml.py
22 lines (13 loc) · 491 Bytes
/
toml.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c) 2024 Phil Thompson <phil@riverbankcomputing.com>
try:
importtomllib
exceptImportError:
importtomliastomllib
deftoml_load(toml_file):
""" Return a dict containing the decoded contents of a TOML file. """
withopen(toml_file, 'rb') asf:
returntomllib.load(f)
deftoml_loads(toml_str):
""" Return a dict containing the decoded contents of a TOML string. """
returntomllib.loads(toml_str)