done
This commit is contained in:
17
lib/python3.11/site-packages/i18n/loaders/yaml_loader.py
Normal file
17
lib/python3.11/site-packages/i18n/loaders/yaml_loader.py
Normal file
@ -0,0 +1,17 @@
|
||||
import yaml
|
||||
|
||||
from .loader import Loader, I18nFileLoadError
|
||||
|
||||
class YamlLoader(Loader):
|
||||
"""class to load yaml files"""
|
||||
def __init__(self):
|
||||
super(YamlLoader, self).__init__()
|
||||
|
||||
def parse_file(self, file_content):
|
||||
try:
|
||||
if hasattr(yaml, "FullLoader"):
|
||||
return yaml.load(file_content, Loader=yaml.FullLoader)
|
||||
else:
|
||||
return yaml.load(file_content)
|
||||
except yaml.scanner.ScannerError as e:
|
||||
raise I18nFileLoadError("invalid YAML: {0}".format(str(e)))
|
Reference in New Issue
Block a user