diff --git a/RTCP/Run/src/util/Parset.py b/RTCP/Run/src/util/Parset.py index 2ccb3d4ca4b04ddec49495a55c70f05431e8f727..b0d1fbb0cce5622260ccfe82757cd45604406daa 100644 --- a/RTCP/Run/src/util/Parset.py +++ b/RTCP/Run/src/util/Parset.py @@ -7,6 +7,8 @@ def isnumeric( x ): float(x) except ValueError: return False + except TypeError: + return False return True @@ -40,20 +42,20 @@ def encode( v ): """ Compress a value v: if v is an array, try using ... or * to shorten ranges. """ def strfy( x ): - if isnumeric( x ): + if isnumeric( x ) or type(x) != str: return str(x) elif reduce( lambda x,y: x or y, map( lambda y: y in x, """ []'",""" ), False ): # if some characters given are present, quote the string if "'" not in x: - return "'%s'" % (str(x)) + return "'%s'" % (x,) elif '"' not in x: - return '"%s"' % (str(x)) + return '"%s"' % (x,) else: # both single and double quotes: use single quotes and escape # existing single quotes with '"'"'. - return "'%s'" % (str.replace( "'", """'"'"'""", str(x) )) + return "'%s'" % (str.replace( "'", """'"'"'""", x )) else: - return str(x) + return x if type(v) != list: # can only compress lists