@@ -163,8 +163,8 @@ def __init__(self):
163163 self .extract_dje_license_error = False
164164
165165 @staticmethod
166- # FIXME: why use a static and not a regular function?
167166 def get_duplicated_keys (input_file ):
167+ # FIXME: why use a static and not a regular function?
168168 csv_context = csv .reader (open (input_file , 'rU' ))
169169 keys_row = csv_context .next ()
170170 lower_case_keys_row = [k .lower () for k in keys_row ]
@@ -173,40 +173,49 @@ def get_duplicated_keys(input_file):
173173 def validate (self , input_list ):
174174 if not self .validate_mandatory_fields (input_list ):
175175 required_keys = MANDATORY_FIELDS + ('about_file' ,)
176- print (" Required keys not found." )
176+ print ('ERROR: Required column/ keys not found in the <input_path> CSV.' )
177177 print (required_keys )
178178 print ("Use the '--mapping' option to map the input keys and verify the mapping information are correct." )
179- print ("OR correct the header keys from the input CSV." )
179+ print ("OR correct the column names in the <input_path> CSV." )
180180 sys .exit (errno .EINVAL )
181181
182182 elif not self .validate_value_in_essential_fields (input_list ):
183- print ("Some of the essential fields value are missing." )
183+ print ("ERROR: Some of the essential column/ fields value are missing in the <input_path> CSV ." )
184184 print (ESSENTIAL_FIELDS )
185- print ("Please check the input CSV." )
186- print ("No ABOUT file is created ." )
185+ print ("Please check the the <input_path> CSV." )
186+ print ("No ABOUT file was generated ." )
187187 sys .exit (errno .EINVAL )
188188
189189 elif has_duplicate_about_file_paths (input_list ):
190- print ("The input has duplicated 'about_file'." )
191- print ("Duplication is not supported. Please correct the input and rerun the tool." )
192- print ("No ABOUT file is created ." )
190+ print ("ERROR: The <input_path> CSV has duplicated 'about_file' values ." )
191+ print ("Duplication is not supported. Please correct the the <input_path> CSV and rerun the tool." )
192+ print ("No ABOUT file was generated ." )
193193 sys .exit (errno .EINVAL )
194194
195195 @staticmethod
196- def validate_mandatory_fields (input_list ):
196+ def validate_mandatory_fields (abouts ):
197+ """
198+ Given a list of About data dictionaries, validate the presence of
199+ mandatory fields. Return True if they are present.
200+ """
197201 # FIXME: why use a static and not a regular function?
198- for line in input_list :
202+
203+ for about in abouts :
199204 for key in MANDATORY_FIELDS + ESSENTIAL_FIELDS :
200- if not key in line . keys () :
205+ if not key in about :
201206 return False
202207 return True
203208
204209 @staticmethod
205- def validate_value_in_essential_fields (input_list ):
210+ def validate_value_in_essential_fields (abouts ):
211+ """
212+ Given a list of About data dictionaries, validate the presence of
213+ essential fields. Return True if they are present.
214+ """
206215 # FIXME: why use a static and not a regular function?
207- for line in input_list :
216+ for about in abouts :
208217 for key in ESSENTIAL_FIELDS :
209- if not line [ key ] :
218+ if not about . get ( key ) :
210219 return False
211220 return True
212221
@@ -604,16 +613,15 @@ def warnings_errors_summary(self):
604613 file_logger .warning (warning_msg )
605614
606615
607- def filter_empty_values (abouts ):
616+ def filter_dicts_of_empty_values (abouts ):
608617 """
609- Return a list of About data dictionaries without any empty value for all
610- key/value pairs .
618+ Return a list of About data dictionaries filtering dictionaries composed
619+ entirely of empty values .
611620 """
612621 filtered = []
613622 for about in abouts :
614- about_items = [(key , value ,) for key , value in about .items () if value and value .strip ()]
615- if about_items :
616- filtered .append (dict (about_items ))
623+ if any (v and v .strip () for v in about .values ()):
624+ filtered .append (dict (about ))
617625 return filtered
618626
619627
@@ -767,7 +775,7 @@ def main(parser, options, args):
767775 file_logger .addHandler (file_handler )
768776
769777 input_data = load_data_from_csv (input_path )
770- input_data = filter_empty_values (input_data )
778+ input_data = filter_dicts_of_empty_values (input_data )
771779
772780 user_keys = []
773781 if mapping_config :
@@ -777,7 +785,7 @@ def main(parser, options, args):
777785
778786 gen .validate (input_data )
779787
780- ignored_fields_list = gen . get_unknown_fields (input_data , user_keys )
788+ ignored_fields_list = get_unknown_fields (input_data , user_keys )
781789 if ignored_fields_list :
782790 input_list = gen .get_only_supported_fields (input_data , ignored_fields_list )
783791
0 commit comments