mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
support json/python types
This commit is contained in:
@@ -324,17 +324,17 @@ unicode_spaces_other = unicode_spaces + [u'(', u')', u'=', u'"']
|
|||||||
|
|
||||||
def string_to_type(t):
|
def string_to_type(t):
|
||||||
if t == 'true':
|
if t == 'true':
|
||||||
return True
|
return unicode(t)
|
||||||
elif t == 'false':
|
elif t == 'false':
|
||||||
return False
|
return unicode(t)
|
||||||
|
|
||||||
if re.search('^[-+]?[0-9]+$',t):
|
if re.search('^[-+]?[0-9]+$',t):
|
||||||
return int(t)
|
return unicode(t)
|
||||||
|
|
||||||
if re.search('^[-+]?[0-9]+\.[0-9]+$',t):
|
if re.search('^[-+]?[0-9]+\.[0-9]+$',t):
|
||||||
return float(t)
|
return unicode(t)
|
||||||
|
|
||||||
return t
|
return u'"' + unicode(t) + u'"'
|
||||||
|
|
||||||
|
|
||||||
class DynamicFilterField(models.TextField):
|
class DynamicFilterField(models.TextField):
|
||||||
@@ -401,9 +401,10 @@ class DynamicFilterField(models.TextField):
|
|||||||
last_kv = new_kv
|
last_kv = new_kv
|
||||||
contains_count += 1
|
contains_count += 1
|
||||||
|
|
||||||
if contains_count == 1 and isinstance(assembled_v, basestring):
|
if contains_count == 1:
|
||||||
assembled_v = '"' + assembled_v + '"'
|
#assembled_v = u'"' + assembled_v + u'"'
|
||||||
elif contains_count > 1:
|
assembled_v = string_to_type(assembled_v)
|
||||||
|
if contains_count > 1:
|
||||||
if type(last_v) is list:
|
if type(last_v) is list:
|
||||||
last_v.append(v)
|
last_v.append(v)
|
||||||
if type(last_v) is dict:
|
if type(last_v) is dict:
|
||||||
@@ -430,7 +431,8 @@ class DynamicFilterField(models.TextField):
|
|||||||
# value
|
# value
|
||||||
# ="something"
|
# ="something"
|
||||||
if t_len > (v_offset + 2) and t[v_offset] == "\"" and t[v_offset + 2] == "\"":
|
if t_len > (v_offset + 2) and t[v_offset] == "\"" and t[v_offset + 2] == "\"":
|
||||||
v = t[v_offset + 1]
|
#v = u'"' + unicode(t[v_offset + 1]) + u'"'
|
||||||
|
v = unicode(t[v_offset + 1])
|
||||||
# empty ""
|
# empty ""
|
||||||
elif t_len > (v_offset + 1):
|
elif t_len > (v_offset + 1):
|
||||||
v = ""
|
v = ""
|
||||||
|
|||||||
Reference in New Issue
Block a user