summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@tsaousis.gr>2018-07-11 02:51:44 +0300
committerGitHub <noreply@github.com>2018-07-11 02:51:44 +0300
commitbe414540bc5e3730c0cb3a70476db8587db868a7 (patch)
tree94deda08e98a9452d4ad685d0cd9f34e83235f4e
parent68d1d56ce86d74250b8e47448a646f93db27ec0e (diff)
parente751407bec348e095fc3b901ecf4064c6cd75660 (diff)
Merge pull request #3949 from l2isbad/yaml_import_fix
python loaders: fallback to yaml package
-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'