summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-05-22 18:04:52 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-07-03 16:08:54 +0200
commit6a409d446ad165e7d3289b18e13e41fc482b0752 (patch)
treee2ef6307a8be8d729ff9ab159c949ae2b6ebc829
parent74cdbc24d1118fa5d54d2c8fc6eec50038418d02 (diff)
qmi-codegen: allow full-line comments in JSON file
We'll just ignore any line starting with //
-rwxr-xr-xbuild-aux/qmi-codegen/qmi-codegen8
-rw-r--r--build-aux/qmi-codegen/utils.py13
2 files changed, 15 insertions, 6 deletions
diff --git a/build-aux/qmi-codegen/qmi-codegen b/build-aux/qmi-codegen/qmi-codegen
index 8f4c978..5f12228 100755
--- a/build-aux/qmi-codegen/qmi-codegen
+++ b/build-aux/qmi-codegen/qmi-codegen
@@ -59,18 +59,14 @@ def codegen_main():
common_object_list_json = []
opts.include.append(opts.input)
for include in opts.include:
- include_file = open(include)
- include_contents = include_file.read()
+ include_contents = utils.read_json_file(include)
include_list = json.loads(include_contents)
for obj in include_list:
if 'common-ref' in obj:
common_object_list_json.append(obj)
- include_file.close()
# Load database file contents
- database_file = open(opts.input)
- database_file_contents = database_file.read()
- database_file.close()
+ database_file_contents = utils.read_json_file(opts.input)
# Get our message collection
object_list_json = json.loads(database_file_contents)
diff --git a/build-aux/qmi-codegen/utils.py b/build-aux/qmi-codegen/utils.py
index 3bc2343..44284f9 100644
--- a/build-aux/qmi-codegen/utils.py
+++ b/build-aux/qmi-codegen/utils.py
@@ -148,3 +148,16 @@ def he_from_le(input_variable, output_variable, variable_type):
def le_from_he(input_variable, output_variable, variable_type):
return he_from_le(input_variable, output_variable, variable_type)
+
+
+def read_json_file(path):
+ f = open(path)
+ out = ''
+ for line in f.readlines():
+ stripped = line.strip()
+ if stripped.startswith('//'):
+ # Skip this line
+ pass
+ else:
+ out += line
+ return out