Skip to content

Commit 1c510c2

Browse files
author
Rob Harrop
committed
Removed use of str.format for compatibility with Python 2.5
1 parent 96166d9 commit 1c510c2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

codegen.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,22 @@ def java_field_type(spec, domain):
9696
return javaTypeMap[spec.resolveDomain(domain)]
9797

9898
def java_field_default_value(type, value):
99+
val_map = {"value" : value}
99100
if type == 'int':
100101
return value
101102
elif type == 'boolean':
102-
return "{0}".format(value).lower()
103+
bool_str = '%(value)s'% val_map
104+
return bool_str.lower()
103105
elif type == 'String':
104-
return "\"{0}\"".format(value)
106+
return '"%(value)s"' % val_map
105107
elif type == 'LongString':
106-
return "LongStringHelper.asLongString(\"{0}\")".format(value)
108+
return 'LongStringHelper.asLongString("%(value)s")' % val_map
107109
elif type == 'long':
108-
return "{0}L".format(value)
110+
return '%(value)sL' % val_map
109111
elif type == 'Map<String,Object>':
110112
return "null"
111113
else:
112-
raise BogusDefaultValue("JSON provided default value {0} for suspicious type {1}".format(value, type))
114+
raise BogusDefaultValue("JSON provided default value %(value)s for suspicious type %(type)s" % {"value" : value, "type" : type})
113115

114116
def typeNameDefault(spec, a):
115117
fieldType = java_field_type(spec, a.domain)

0 commit comments

Comments
 (0)