summaryrefslogtreecommitdiff
path: root/jsongen.py
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2017-07-01 15:48:06 -0700
committerGary E. Miller <gem@rellim.com>2017-07-01 15:48:06 -0700
commit1f198d8dbc3fec72240e76be58ff57c4cca0a29e (patch)
tree8d790324310fc215a264010fe06a3a80d44ad989 /jsongen.py
parente60ecd383e1c24e9a7e9a4328fb3ac2bb019ab27 (diff)
downloadgpsd-1f198d8dbc3fec72240e76be58ff57c4cca0a29e.tar.gz
jsongen.py: pep8 fixes
Diffstat (limited to 'jsongen.py')
-rwxr-xr-xjsongen.py95
1 files changed, 54 insertions, 41 deletions
diff --git a/jsongen.py b/jsongen.py
index db1f27f5..cf223a88 100755
--- a/jsongen.py
+++ b/jsongen.py
@@ -12,7 +12,8 @@
# Preserve this property!
from __future__ import absolute_import, print_function, division
-import sys, getopt
+import getopt
+import sys
#
# Here is the information that makes it all work - attribute, type, and
@@ -304,14 +305,14 @@ ais_specs = (
('day', 'uinteger', 'AIS_DAY_NOT_AVAILABLE'),
('tidals', 'array', (
('tidal_t', 'ntidals', (
- ('lon', 'integer', 'AIS_LON3_NOT_AVAILABLE'),
- ('lat', 'integer', 'AIS_LAT3_NOT_AVAILABLE'),
- ('from_hour', 'uinteger', 'AIS_MONTH_NOT_AVAILABLE'),
- ('from_min', 'uinteger', 'AIS_MINUTE_NOT_AVAILABLE'),
- ('to_hour', 'uinteger', 'AIS_HOUR_NOT_AVAILABLE'),
- ('to_min', 'uinteger', 'AIS_MINUTE_NOT_AVAILABLE'),
- ('cdir', 'uinteger', 'DAC1FID32_CDIR_NOT_AVAILABLE'),
- ('cspeed', 'uinteger', 'DAC1FID32_CSPEED_NOT_AVAILABLE'),
+ ('lon', 'integer', 'AIS_LON3_NOT_AVAILABLE'),
+ ('lat', 'integer', 'AIS_LAT3_NOT_AVAILABLE'),
+ ('from_hour', 'uinteger', 'AIS_MONTH_NOT_AVAILABLE'),
+ ('from_min', 'uinteger', 'AIS_MINUTE_NOT_AVAILABLE'),
+ ('to_hour', 'uinteger', 'AIS_HOUR_NOT_AVAILABLE'),
+ ('to_min', 'uinteger', 'AIS_MINUTE_NOT_AVAILABLE'),
+ ('cdir', 'uinteger', 'DAC1FID32_CDIR_NOT_AVAILABLE'),
+ ('cspeed', 'uinteger', 'DAC1FID32_CSPEED_NOT_AVAILABLE'),
)))),
),
},
@@ -386,10 +387,12 @@ ais_specs = (
('humidity', 'uinteger', 'DAC1FID11_HUMIDITY_NOT_AVAILABLE'),
('dewpoint', 'uinteger', 'DAC1FID11_DEWPOINT_NOT_AVAILABLE'),
('pressure', 'uinteger', 'DAC1FID11_PRESSURE_NOT_AVAILABLE'),
- ('pressuretend', 'uinteger', 'DAC1FID11_PRESSURETREND_NOT_AVAILABLE'),
- ('visibility', 'uinteger', 'DAC1FID11_VISIBILITY_NOT_AVAILABLE'),
- ('waterlevel', 'integer', 'DAC1FID11_WATERLEVEL_NOT_AVAILABLE'),
- ('leveltrend', 'uinteger', 'DAC1FID11_WATERLEVELTREND_NOT_AVAILABLE'),
+ ('pressuretend', 'uinteger',
+ 'DAC1FID11_PRESSURETREND_NOT_AVAILABLE'),
+ ('visibility', 'uinteger', 'DAC1FID11_VISIBILITY_NOT_AVAILABLE'),
+ ('waterlevel', 'integer', 'DAC1FID11_WATERLEVEL_NOT_AVAILABLE'),
+ ('leveltrend', 'uinteger',
+ 'DAC1FID11_WATERLEVELTREND_NOT_AVAILABLE'),
('cspeed', 'uinteger', 'DAC1FID11_CSPEED_NOT_AVAILABLE'),
('cdir', 'uinteger', 'DAC1FID11_CDIR_NOT_AVAILABLE'),
('cspeed2', 'uinteger', 'DAC1FID11_CSPEED_NOT_AVAILABLE'),
@@ -398,19 +401,19 @@ ais_specs = (
('cspeed3', 'uinteger', 'DAC1FID11_CSPEED_NOT_AVAILABLE'),
('cdir3', 'uinteger', 'DAC1FID11_CDIR_NOT_AVAILABLE'),
('cdepth3', 'uinteger', 'DAC1FID11_CDEPTH_NOT_AVAILABLE'),
- ('waveheight', 'uinteger', 'DAC1FID11_WAVEHEIGHT_NOT_AVAILABLE'),
- ('waveperiod', 'uinteger', 'DAC1FID11_WAVEPERIOD_NOT_AVAILABLE'),
- ('wavedir', 'uinteger', 'DAC1FID11_WAVEDIR_NOT_AVAILABLE'),
- ('swellheight', 'uinteger', 'DAC1FID11_WAVEHEIGHT_NOT_AVAILABLE'),
- ('swellperiod', 'uinteger', 'DAC1FID11_WAVEPERIOD_NOT_AVAILABLE'),
- ('swelldir', 'uinteger', 'DAC1FID11_WAVEDIR_NOT_AVAILABLE'),
- ('seastate', 'uinteger', 'DAC1FID11_SEASTATE_NOT_AVAILABLE'),
- ('watertemp', 'uinteger', 'DAC1FID11_WATERTEMP_NOT_AVAILABLE'),
- ('preciptype', 'uinteger', 'DAC1FID11_PRECIPTYPE_NOT_AVAILABLE'),
+ ('waveheight', 'uinteger', 'DAC1FID11_WAVEHEIGHT_NOT_AVAILABLE'),
+ ('waveperiod', 'uinteger', 'DAC1FID11_WAVEPERIOD_NOT_AVAILABLE'),
+ ('wavedir', 'uinteger', 'DAC1FID11_WAVEDIR_NOT_AVAILABLE'),
+ ('swellheight', 'uinteger', 'DAC1FID11_WAVEHEIGHT_NOT_AVAILABLE'),
+ ('swellperiod', 'uinteger', 'DAC1FID11_WAVEPERIOD_NOT_AVAILABLE'),
+ ('swelldir', 'uinteger', 'DAC1FID11_WAVEDIR_NOT_AVAILABLE'),
+ ('seastate', 'uinteger', 'DAC1FID11_SEASTATE_NOT_AVAILABLE'),
+ ('watertemp', 'uinteger', 'DAC1FID11_WATERTEMP_NOT_AVAILABLE'),
+ ('preciptype', 'uinteger', 'DAC1FID11_PRECIPTYPE_NOT_AVAILABLE'),
('preciptype_text', 'ignore', None),
- ('salinity', 'uinteger', 'DAC1FID11_SALINITY_NOT_AVAILABLE'),
- ('ice', 'uinteger', 'DAC1FID11_ICE_NOT_AVAILABLE'),
- ('ice_text', 'ignore', None),
+ ('salinity', 'uinteger', 'DAC1FID11_SALINITY_NOT_AVAILABLE'),
+ ('ice', 'uinteger', 'DAC1FID11_ICE_NOT_AVAILABLE'),
+ ('ice_text', 'ignore', None),
),
"stringbuffered": ("timestamp",),
},
@@ -469,9 +472,9 @@ ais_specs = (
("id.other", 'string', 'DAC1FID17_ID_LENGTH'),
('lat', 'integer', 'AIS_LAT3_NOT_AVAILABLE'),
('lon', 'integer', 'AIS_LON3_NOT_AVAILABLE'),
- ('course', 'uinteger', 'DAC1FID17_COURSE_NOT_AVAILABLE'),
- ('second', 'uinteger', 'AIS_SECOND_NOT_AVAILABLE'),
- ('speed', 'uinteger', 'DAC1FID17_SPEED_NOT_AVAILABLE'),
+ ('course', 'uinteger', 'DAC1FID17_COURSE_NOT_AVAILABLE'),
+ ('second', 'uinteger', 'AIS_SECOND_NOT_AVAILABLE'),
+ ('speed', 'uinteger', 'DAC1FID17_SPEED_NOT_AVAILABLE'),
)))),
),
},
@@ -526,8 +529,8 @@ ais_specs = (
('country', 'string', None),
('gauges', 'array', (
('gauge_t', 'ngauges', (
- ('id', 'uinteger', 'DAC200FID24_GAUGE_ID_UNKNOWN'),
- ('level', 'integer', 'DAC200FID24_GAUGE_LEVEL_UNKNOWN'),
+ ('id', 'uinteger', 'DAC200FID24_GAUGE_ID_UNKNOWN'),
+ ('level', 'integer', 'DAC200FID24_GAUGE_LEVEL_UNKNOWN'),
)))),
),
},
@@ -579,11 +582,13 @@ ais_specs = (
('humidity', 'uinteger', 'DAC1FID31_HUMIDITY_NOT_AVAILABLE'),
('dewpoint', 'integer', 'DAC1FID31_DEWPOINT_NOT_AVAILABLE'),
('pressure', 'uinteger', 'DAC1FID31_PRESSURE_NOT_AVAILABLE'),
- ('pressuretend', 'uinteger', 'DAC1FID31_PRESSURETEND_NOT_AVAILABLE'),
+ ('pressuretend', 'uinteger',
+ 'DAC1FID31_PRESSURETEND_NOT_AVAILABLE'),
('visgreater', 'boolean', 'false'),
('visibility', 'uinteger', 'DAC1FID31_VISIBILITY_NOT_AVAILABLE'),
('waterlevel', 'integer', 'DAC1FID31_WATERLEVEL_NOT_AVAILABLE'),
- ('leveltrend', 'uinteger', 'DAC1FID31_WATERLEVELTREND_NOT_AVAILABLE'),
+ ('leveltrend', 'uinteger',
+ 'DAC1FID31_WATERLEVELTREND_NOT_AVAILABLE'),
('cspeed', 'uinteger', 'DAC1FID31_CSPEED_NOT_AVAILABLE'),
('cdir', 'uinteger', 'DAC1FID31_DIR_NOT_AVAILABLE'),
('cspeed2', 'uinteger', 'DAC1FID31_CSPEED_NOT_AVAILABLE'),
@@ -951,16 +956,20 @@ def generate(spec):
for (attr, itype, arrayparts) in spec["fieldmap"]:
if itype == 'array':
(innerstruct, lengthfield, elements) = arrayparts
- report += " const struct json_attr_t %s_%s_subtype[] = {\n" % (initname, attr)
+ report += (" const struct json_attr_t %s_%s_subtype[] = {\n"
+ % (initname, attr))
for (subattr, subitype, default) in elements:
- report += '\t{"%s",%st_%s,%sSTRUCTOBJECT(struct %s, %s),\n' % \
- (subattr, " " * (14 - len(subattr)), subitype, " " * (8 - len(subitype)), innerstruct, subattr)
+ report += ('\t{"%s",%st_%s,%sSTRUCTOBJECT(struct %s, %s),\n'
+ % (subattr, " " * (14 - len(subattr)), subitype,
+ " " * (8 - len(subitype)), innerstruct, subattr))
if subitype != "string":
- report += leader + ".dflt.%s = %s},\n" % (subitype, default)
+ report += (leader + ".dflt.%s = %s},\n"
+ % (subitype, default))
elif default:
report += leader + ".len = %s},\n" % (default,)
else:
- sys.stderr.write("explicit length specification required\n")
+ sys.stderr.write(
+ "explicit length specification required\n")
raise SystemExit(1)
report += """\
{NULL}
@@ -975,8 +984,10 @@ def generate(spec):
for (attr, itype, default) in spec["fieldmap"]:
if itype == 'array':
(innerstruct, lengthfield, elements) = default
- report += '\t{"%s",%st_array, STRUCTARRAY(%s.%s, %s_%s_subtype, &%s.%s)},\n' \
- % (attr, " " * (14 - len(attr)), structname, attr, initname, attr, structname, lengthfield)
+ report += ('\t{"%s",%st_array, '
+ 'STRUCTARRAY(%s.%s, %s_%s_subtype, &%s.%s)},\n'
+ % (attr, " " * (14 - len(attr)), structname, attr,
+ initname, attr, structname, lengthfield))
else:
if itype == "string":
deref = ""
@@ -992,7 +1003,8 @@ def generate(spec):
report += '\t{"%s", t_ignore},\n' % attr
continue
report += '\t{"%s",%st_%s,%s.addr.%s = %s%s,\n' % \
- (attr, " " * (14 - len(attr)), itype, " " * (10 - len(itype)), itype, deref, target)
+ (attr, " " * (14 - len(attr)), itype, " " * (10 - len(itype)),
+ itype, deref, target)
if itype == "string":
report += leader + ".len = sizeof(%s)},\n" % target
else:
@@ -1008,7 +1020,8 @@ if __name__ == '__main__':
# The --ais and --target= options are (required) placeholders.
# In the future, this script will generate more different kinds
# of code.
- (options, arguments) = getopt.getopt(sys.argv[1:], "", ["ais", "target="])
+ (options, arguments) = getopt.getopt(sys.argv[1:], "",
+ ["ais", "target="])
except getopt.GetoptError as msg:
print("jsongen.py: " + str(msg))
raise SystemExit(1)