userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
yaml_util.py
1
import
yaml
2
import
yaml.parser
3
4
from
testsuite.utils
import
object_hook
as
object_hook_util
5
6
7
class
BaseError
(Exception):
8
pass
9
10
11
class
ParserError
(
BaseError
):
12
pass
13
14
15
if
hasattr(yaml,
'CLoader'
):
16
_Loader = yaml.CLoader
# type: ignore
17
else
:
18
_Loader = yaml.Loader
# type: ignore
19
20
21
def
load_file(path, encoding='utf-8', object_hook=None):
22
with
open(path, encoding=encoding)
as
fp:
23
return
load(fp, object_hook=object_hook)
24
25
26
def
load(string_or_stream, object_hook=None):
27
try
:
28
yaml_obj = yaml.load(string_or_stream, Loader=_Loader)
29
hook = object_hook_util.build_object_hook(object_hook=object_hook)
30
return
object_hook_util.substitute(yaml_obj, hook)
31
except
yaml.parser.ParserError
as
exc:
32
raise
ParserError(str(exc))
from
exc
en
testsuite
utils
yaml_util.py
Generated on
for userver by
Doxygen
1.17.0