NxosCmdRef: fix python2 ordereddict import (#58397)

* NxosCmdRef: fix ordereddict import checks for pre-2.7

* Fix ws
This commit is contained in:
Chris Van Heuveln 2019-07-03 00:11:29 -04:00 committed by Trishna Guha
parent ee4cba1b85
commit 6c5de9e6eb

View file

@ -31,6 +31,7 @@
import collections
import json
import re
import sys
from ansible.module_utils._text import to_text
from ansible.module_utils.basic import env_fallback
@ -48,10 +49,10 @@ except ImportError:
HAS_YAML = False
try:
if PY3:
from collections import OrderedDict
else:
if sys.version_info[:2] < (2, 7):
from ordereddict import OrderedDict
else:
from collections import OrderedDict
HAS_ORDEREDDICT = True
except ImportError:
HAS_ORDEREDDICT = False
@ -1115,7 +1116,7 @@ def nxosCmdRef_import_check():
"""Return import error messages or empty string"""
msg = ''
if PY2:
if not HAS_ORDEREDDICT:
if not HAS_ORDEREDDICT and sys.version_info[:2] < (2, 7):
msg += "Mandatory python library 'ordereddict' is not present, try 'pip install ordereddict'\n"
if not HAS_YAML:
msg += "Mandatory python library 'yaml' is not present, try 'pip install yaml'\n"