mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-26 07:18:31 +01:00
Following up on https://github.com/iterative/dvc/pull/7965#discussion_r912684074 Co-authored-by: David de la Iglesia Castro <[email protected]>
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
from collections import defaultdict
|
|
from typing import DefaultDict
|
|
|
|
from ._common import * # noqa, pylint: disable=wildcard-import
|
|
from ._json import * # noqa, pylint: disable=wildcard-import
|
|
from ._py import * # noqa, pylint: disable=wildcard-import
|
|
from ._toml import * # noqa, pylint: disable=wildcard-import
|
|
from ._yaml import * # noqa, pylint: disable=wildcard-import
|
|
|
|
LOADERS: DefaultDict[str, LoaderFn] = defaultdict( # noqa: F405
|
|
lambda: load_yaml # noqa: F405
|
|
)
|
|
LOADERS.update(
|
|
{".toml": load_toml, ".json": load_json, ".py": load_py} # noqa: F405
|
|
)
|
|
|
|
|
|
def load_path(fs_path, fs):
|
|
suffix = fs.path.suffix(fs_path).lower()
|
|
loader = LOADERS[suffix]
|
|
return loader(fs_path, fs=fs)
|
|
|
|
|
|
DUMPERS: DefaultDict[str, DumperFn] = defaultdict( # noqa: F405
|
|
lambda: dump_yaml # noqa: F405
|
|
)
|
|
DUMPERS.update(
|
|
{".toml": dump_toml, ".json": dump_json, ".py": dump_py} # noqa: F405
|
|
)
|
|
|
|
MODIFIERS: DefaultDict[str, ModifierFn] = defaultdict( # noqa: F405
|
|
lambda: modify_yaml # noqa: F405
|
|
)
|
|
MODIFIERS.update(
|
|
{
|
|
".toml": modify_toml, # noqa: F405
|
|
".json": modify_json, # noqa: F405
|
|
".py": modify_py, # noqa: F405
|
|
}
|
|
)
|