mfg_util: Add support for comments in input config csv file only

This commit is contained in:
Shivani Tipnis 2019-04-04 16:01:40 +05:30
parent 3368783bf0
commit 4be28a798f
3 changed files with 7 additions and 5 deletions

View File

@ -181,3 +181,5 @@ The mfg\_gen.py utility is using the generated CSV Configuration file and Master
.. note:: The default numeric value: 1,2,3... of ``fileid`` argument, corresponds to each row having device instance values in master csv values file.
.. note:: ``bin/`` **and** ``csv/`` **sub-directories are created in the** ``outdir`` **directory specified while running this utility. The binary files generated will be stored in** ``bin/`` **and the intermediate csv files generated will be stored in** ``csv/``.
.. note:: Comments are supported in input config csv file only.

View File

@ -55,7 +55,7 @@ def verify_keys_exist(values_file_keys, input_config_file):
keys_missing = []
config_file = open(input_config_file,'r')
config_file_reader = csv.reader(config_file, delimiter=',')
config_file_reader = csv.reader(filter(lambda row: row[0] != '#',config_file), delimiter=',')
for line_no, config_data in enumerate(config_file_reader,1):
if 'namespace' not in config_data:
if values_file_keys:
@ -84,7 +84,7 @@ def verify_datatype_encoding(input_config_file):
line_no = 0
config_file = open(input_config_file,'r')
config_file_reader = csv.reader(config_file, delimiter=',')
config_file_reader = csv.reader(filter(lambda row: row[0] != '#',config_file), delimiter=',')
for config_data in config_file_reader:
line_no += 1
if config_data[1] not in valid_datatypes:
@ -102,7 +102,7 @@ def verify_file_data_count(input_config_file, keys_repeat):
"""
line_no = 0
config_file = open(input_config_file, 'r')
config_file_reader = csv.reader(config_file, delimiter=',')
config_file_reader = csv.reader(filter(lambda row: row[0] != '#',config_file), delimiter=',')
for line in config_file_reader:
line_no += 1
if len(line) != 3 and line[0] not in keys_repeat:
@ -155,7 +155,7 @@ def add_config_data_per_namespace(input_config_file):
config_data_per_namespace = []
csv_config_file = open(input_config_file,'r')
config_file_reader = csv.reader(csv_config_file, delimiter=',')
config_file_reader = csv.reader(filter(lambda row: row[0] != '#',csv_config_file), delimiter=',')
# `config_data_per_namespace` is added to `config_data_to_write` list after reading next namespace
for config_data in config_file_reader:
@ -515,7 +515,6 @@ def main(input_config_file=None,input_values_file=None,target_file_name_prefix=N
output_target_dir = create_dir("bin/", output_dir_path)
# Verify if output bin file does not exist
# todo for keys
output_file_prefix = target_file_name_prefix + "-" + file_identifier_value
output_bin_file = output_target_dir + output_file_prefix + ".bin"
if os.path.isfile(output_bin_file):

View File

@ -1,3 +1,4 @@
# Sample config file
dummyNamespace,namespace,
dummyU8Key,data,u8
dummyI8Key,data,i8

1 dummyNamespace,namespace, # Sample config file
1 # Sample config file
2 dummyNamespace,namespace, dummyNamespace,namespace,
3 dummyU8Key,data,u8 dummyU8Key,data,u8
4 dummyI8Key,data,i8 dummyI8Key,data,i8