summaryrefslogtreecommitdiffstats
path: root/python.d/python_modules
diff options
context:
space:
mode:
authorlgz <ilyamaschenko@gmail.com>2018-07-09 23:41:50 +0900
committerlgz <ilyamaschenko@gmail.com>2018-07-09 23:41:50 +0900
commite751407bec348e095fc3b901ecf4064c6cd75660 (patch)
tree1bef4669e783ffe7a9f1294e81481c82c87f15eb /python.d/python_modules
parente873f63acaa3a27facb5ac62d951a53122d14b52 (diff)
python loaders: fallback to yaml package
Diffstat (limited to 'python.d/python_modules')
-rw-r--r--python.d/python_modules/bases/loaders.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/python.d/python_modules/bases/loaders.py b/python.d/python_modules/bases/loaders.py
index 6f2cf7bd09..debc69f239 100644
--- a/python.d/python_modules/bases/loaders.py
+++ b/python.d/python_modules/bases/loaders.py
@@ -4,16 +4,24 @@
# SPDX-License-Identifier: GPL-3.0+
import types
+
from sys import version_info
PY_VERSION = version_info[:2]
+try:
+ if PY_VERSION > (3, 1):
+ from pyyaml3 import SafeLoader as YamlSafeLoader
+ else:
+ from pyyaml2 import SafeLoader as YamlSafeLoader
+except ImportError:
+ from yaml import SafeLoader as YamlSafeLoader
+
+
if PY_VERSION > (3, 1):
- from pyyaml3 import SafeLoader as YamlSafeLoader
from importlib.machinery import SourceFileLoader
DEFAULT_MAPPING_TAG = 'tag:yaml.org,2002:map'
else:
- from pyyaml2 import SafeLoader as YamlSafeLoader
from imp import load_source as SourceFileLoader
DEFAULT_MAPPING_TAG = u'tag:yaml.org,2002:map'