Unverified Commit cd007bb7 authored by Jeffrey Booher-Kaeding's avatar Jeffrey Booher-Kaeding Committed by GitHub
Browse files

Merge pull request #9 from vstehle/for-zhifei

A fix for old python3 yaml versions
parents ce6ecaf4 d20f6f54
......@@ -7,6 +7,7 @@ import argparse
import csv
import logging
import json
from packaging import version
try:
import yaml
......@@ -19,6 +20,12 @@ if 'yaml' in sys.modules:
except ImportError:
from yaml import Dumper
# Not all yaml versions have a Loader argument.
if version.parse(yaml.__version__) >= version.parse('5.1'):
yaml_load_args = {'Loader': yaml.FullLoader}
else:
yaml_load_args = {}
#based loosley on https://stackoverflow.com/a/4391978
# returns a filtered dict of dicts that meet some Key-value pair.
......@@ -301,7 +308,7 @@ def use_config(cross_check, filename):
logging.debug(f'Read {filename}')
with open(filename, 'r') as yamlfile:
conf = yaml.load(yamlfile, Loader=yaml.FullLoader)
conf = yaml.load(yamlfile, **yaml_load_args)
logging.debug('{} rule(s)'.format(len(conf)))
sanitize_yaml(conf)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment