Skip to content

Commit 4d4301d

Browse files
author
Slavek Kabrda
authored
Support pyyaml < 5.1 (#66)
1 parent 25721d1 commit 4d4301d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

datadog_callback.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,14 @@ def _set_logger_level(self, name, level=logging.WARNING):
6969
def _load_conf(self, file_path):
7070
conf_dict = {}
7171
if os.path.isfile(file_path):
72+
try:
73+
loader = yaml.FullLoader
74+
except AttributeError:
75+
# on pyyaml < 5.1, there's no FullLoader,
76+
# but we can still use SafeLoader
77+
loader = yaml.SafeLoader
7278
with open(file_path, 'r') as conf_file:
73-
conf_dict = yaml.load(conf_file, Loader=yaml.FullLoader)
79+
conf_dict = yaml.load(conf_file, Loader=loader)
7480

7581
api_key = os.environ.get('DATADOG_API_KEY', conf_dict.get('api_key', ''))
7682
dd_url = os.environ.get('DATADOG_URL', conf_dict.get('url', ''))

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
datadog
2-
pyyaml>=5.1
2+
pyyaml>=3.10
33
packaging

0 commit comments

Comments
 (0)