Add loader for pyproject.toml
This commit is contained in:
parent
68bbefea52
commit
3f1ff5404f
@ -298,6 +298,21 @@ def break_lines(lines, width):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def load_pyproject_toml(dirname, maxdepth=3, filename='pyproject.toml'):
|
||||||
|
"""Find and load pyproject.toml of current project."""
|
||||||
|
|
||||||
|
for _ in range(maxdepth):
|
||||||
|
if filename in os.listdir(dirname):
|
||||||
|
with open(os.path.join(dirname, filename), 'rb') as f:
|
||||||
|
config = tomllib.load(f)
|
||||||
|
return config.get('tool', {}).get('magicli', {})
|
||||||
|
|
||||||
|
# Go to parent directory
|
||||||
|
dirname = os.path.abspath(os.path.join(dirname, os.pardir))
|
||||||
|
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
def first_calling_frame():
|
def first_calling_frame():
|
||||||
for s in reversed(inspect.stack()):
|
for s in reversed(inspect.stack()):
|
||||||
if s.code_context == None:
|
if s.code_context == None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user