copied directly from ansible/lib/utils/__init__.py