summaryrefslogtreecommitdiff
path: root/devtools/tablegen.py
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2013-10-01 06:37:53 -0400
committerEric S. Raymond <esr@thyrsus.com>2013-10-01 06:37:53 -0400
commit10374a53fcef50b599ab83848df3eb61b0fb7df4 (patch)
treeebfa0420534664095b2facb14e9f077ff55b74a7 /devtools/tablegen.py
parentb16d117a0a86a64944f012d844bdabd6e696c74e (diff)
downloadgpsd-10374a53fcef50b599ab83848df3eb61b0fb7df4.tar.gz
Minor improvements to tablegen.py.
Diffstat (limited to 'devtools/tablegen.py')
-rwxr-xr-xdevtools/tablegen.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/devtools/tablegen.py b/devtools/tablegen.py
index 8af319ab..1e34a60f 100755
--- a/devtools/tablegen.py
+++ b/devtools/tablegen.py
@@ -272,11 +272,11 @@ def make_json_dumper(wfp):
continue
# At end of tuples, or if scaled flag changes, or if next op is array,
# flush out dump code for a span of fields.
- if tuples[i+1][1] == None:
- endit = r',\"%s\":['
- elif i+1 == len(tuples):
+ if i+1 == len(tuples):
if not inarray:
endit = '}\r\n'
+ elif tuples[i+1][1] == None:
+ endit = r',\"%s\":['
elif scaled(i) != scaled(i+1):
endit = '.",'
else:
@@ -388,7 +388,7 @@ def make_json_generator(wfp):
't': "string",
'd': "string",
}[ftype[0]]
- default = {
+ typedefault = {
'u': "'PUT_DEFAULT_HERE'",
'U': "'PUT_DEFAULT_HERE'",
'e': "'PUT DEFAULT HERE'",
@@ -397,6 +397,14 @@ def make_json_generator(wfp):
'b': "\'false\'",
't': "None",
}[ftype[0]]
+ namedefaults = {
+ "month": "'0'",
+ "day": "'0'",
+ "hour": "'24'",
+ "minute": "'60'",
+ "second": "'60'",
+ }
+ default = namedefaults.get(name) or typedefault
print >>wfp, extra + " ('%s',%s '%s',%s %s)," % (name,
" "*(10-len(name)),
readtype,