@@ -71,15 +71,38 @@ def component_subset_to_sublist(input_list):
7171def update_path_to_about (input_list ):
7272 output_list = []
7373 for row in input_list :
74- if row .endswith ('/' ):
75- row = row .rpartition ('/' )[0 ]
76- output_list .append (row + '.ABOUT' )
74+ if not row .endswith ('.ABOUT' ):
75+ if row .endswith ('/' ):
76+ row = row .rpartition ('/' )[0 ]
77+ output_list .append (row + '.ABOUT' )
78+ else :
79+ output_list .append (row )
7780 return output_list
7881
82+ def convert_dict_key_to_lower_case (input_list ):
83+ output_list = []
84+ for line in input_list :
85+ dict = {}
86+ for key in line :
87+ dict [key .lower ()] = line [key ]
88+ output_list .append (dict )
89+ return output_list
90+
91+ def check_about_file_existance_and_format (input_list ):
92+ try :
93+ for row in input_list :
94+ # Force the path to start with the '/' to do the mapping
95+ # with the project structure
96+ if not row ['about_file' ].startswith ('/' ):
97+ row ['about_file' ] = '/' + row ['about_file' ]
98+ return input_list
99+ except Exception as e :
100+ return []
101+
79102USAGE_SYNTAX = """\
80103 Input can be a file or directory.
81104 Output of rendered template must be a file (e.g. .html).
82- Component List must be a .csv file which has at least an "about_resource " column.
105+ Component List must be a .csv file which has at least an "about_file " column.
83106"""
84107
85108VERBOSITY_HELP = """\
@@ -156,22 +179,25 @@ def main(parser, options, args):
156179
157180 if not exists (output_path ) or (exists (output_path ) and overwrite ):
158181 collector = AboutCollector (input_path )
159- input_list = []
160182 if not component_subset_path :
161183 sublist = None
162184 else :
185+ input_list = []
163186 with open (component_subset_path , "rU" ) as f :
164187 input_dict = csv .DictReader (f )
165188 for row in input_dict :
166- # Force the path to start with the '/' to do the mapping
167- # with the project structure
168- if not row ['about_file' ].startswith ('/' ):
169- row ['about_file' ] = '/' + row ['about_file' ]
170189 input_list .append (row )
190+ updated_list = convert_dict_key_to_lower_case (input_list )
171191 if mapping_config :
172192 mapping_list = genabout .GenAbout ().get_mapping_list ()
173- input_list = genabout .GenAbout ().convert_input_list (input_list , mapping_list )
174- sublist = component_subset_to_sublist (input_list )
193+ updated_list = genabout .GenAbout ().convert_input_list (updated_list , mapping_list )
194+ if not check_about_file_existance_and_format (updated_list ):
195+ print ("The required key, 'about_file, not found." )
196+ print ("Please use the '--mapping' option to map the input keys and verify the mapping information are correct." )
197+ print ("OR, correct the header keys from the component list." )
198+ parser .print_help ()
199+ sys .exit (errno .EISDIR )
200+ sublist = component_subset_to_sublist (updated_list )
175201 outlist = update_path_to_about (sublist )
176202
177203 attrib_str = collector .generate_attribution (template_path = template_location , limit_to = outlist )
0 commit comments