Skip to content

Commit

Permalink
refactor: migrate to tomllib/tomli
Browse files Browse the repository at this point in the history
  • Loading branch information
kalekundert committed Aug 31, 2023
1 parent 7356fcb commit e82518f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ dynamic = ["version", "description"]
requires-python = "~=3.7"
dependencies = [
'pandas',
'toml>=0.10',
'inform>=1.15',
'tomli >= 1.1.0 ; python_version < 3.11',
'inform >= 1.15',
'docopt', # gui
'matplotlib', # gui
'colorcet', # gui
Expand Down
18 changes: 11 additions & 7 deletions wellmap/file.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
#!/usr/bin/env python3

import toml
import sys, re, itertools, inspect
import pandas as pd

from pathlib import Path
from inform import plural
from copy import deepcopy
from .util import *

try:
import tomllib
except ModuleNotFoundError:
import tomli as tomllib

# Data Structures
# ===============
# `config`
Expand Down Expand Up @@ -321,12 +326,11 @@ def config_from_toml(toml_path, *, shift=(0,0), path_guess=None, path_required=F
settings.
"""
toml_path = Path(toml_path).resolve()
config = configdict(
shift_config(
toml.load(str(toml_path)),
shift,
),
)

with open(toml_path, 'rb') as f:
toml_data = tomllib.load(f)

config = configdict(shift_config(toml_data, shift))
concats = []
deps = {toml_path}

Expand Down

0 comments on commit e82518f

Please sign in to comment.