From 0997552722dc4845a854e0e6f8d7f18058e26380 Mon Sep 17 00:00:00 2001 From: shangxdy Date: Fri, 8 Jul 2016 15:15:00 +0800 Subject: Synchronise the openstack bugs When run unittests through tox, some test cases are always error, the errors are already done in openstack community, so it's necessary to synchronise the fixes. Change-Id: Ib29078e6cc138a474e89c6a2cc90ad7a1db1bb46 JIRA: PARSER-63 Signed-off-by: shangxdy --- tosca2heat/heat-translator/translator/common/utils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tosca2heat/heat-translator/translator/common') diff --git a/tosca2heat/heat-translator/translator/common/utils.py b/tosca2heat/heat-translator/translator/common/utils.py index 459b5ee..8e4b690 100644 --- a/tosca2heat/heat-translator/translator/common/utils.py +++ b/tosca2heat/heat-translator/translator/common/utils.py @@ -18,6 +18,7 @@ import numbers import os import re import requests +import six from six.moves.urllib.parse import urlparse import yaml @@ -262,12 +263,17 @@ class UrlUtils(object): def str_to_num(value): """Convert a string representation of a number into a numeric type.""" - if isinstance(value, numbers.Number): + if isinstance(value, numbers.Number) \ + or isinstance(value, six.integer_types) \ + or isinstance(value, float): return value try: return int(value) except ValueError: - return float(value) + try: + return float(value) + except ValueError: + return None def check_for_env_variables(): -- cgit 1.2.3-korg