@@ -69,6 +69,13 @@ def __init__(self):
6969 self .errors = []
7070 self .extract_dje_license_error = False
7171
72+ @staticmethod
73+ def get_duplicated_keys (input_file ):
74+ csv_context = csv .reader (open (input_file ))
75+ keys_row = csv_context .next ()
76+ lower_case_keys_row = [k .lower () for k in keys_row ]
77+ return ([key for key in keys_row if lower_case_keys_row .count (key .lower ()) > 1 ])
78+
7279 @staticmethod
7380 def get_input_list (input_file ):
7481 csvfile = csv .DictReader (open (input_file , 'rU' ))
@@ -203,7 +210,7 @@ def verify_license_files(self, input_list, project_dir, license_in_project):
203210 if _exists (license_file_path ):
204211 license_files_list .append ((license_file_path , about_parent_dir ))
205212 else :
206- self .warnings .append (Warn ('license_text_file' , license_file_path , "License doesn't exist." ))
213+ self .warnings .append (Warn ('license_text_file' , license_file_path , "License does not exist." ))
207214 except Exception as e :
208215 print (repr (e ))
209216 print ("The input does not have the 'license_text_file' key which is required." )
@@ -301,7 +308,7 @@ def get_dje_license_list(self, gen_location, input_list, gen_license):
301308 about_parent_dir = dirname (file_location )
302309 license_file = gen_location .rpartition ('/' )[0 ] + join (about_parent_dir , line ['license_text_file' ])
303310 if not _exists (license_file ):
304- self .errors .append (Error ('license_text_file' , license_file , "The 'license_text_file' doesn't exist." ))
311+ self .errors .append (Error ('license_text_file' , license_file , "The 'license_text_file' does not exist." ))
305312 else :
306313 if gen_license :
307314 if line ['dje_license_key' ]:
@@ -514,17 +521,17 @@ def main(parser, options, args):
514521
515522 if copy_license_path :
516523 if not _exists (copy_license_path ):
517- print ("The project path doesn't exist." )
524+ print ("The project path does not exist." )
518525 sys .exit (errno .EINVAL )
519526
520527 if license_text_path :
521528 if not _exists (license_text_path ):
522- print ("The license text path doesn't exist." )
529+ print ("The license text path does not exist." )
523530 sys .exit (errno .EINVAL )
524531
525532 if mapping_config :
526533 if not _exists ('MAPPING.CONFIG' ):
527- print ("The file 'MAPPING.CONFIG' doesn't exist." )
534+ print ("The file 'MAPPING.CONFIG' does not exist." )
528535 sys .exit (errno .EINVAL )
529536
530537 if extract_license :
@@ -566,6 +573,13 @@ def main(parser, options, args):
566573
567574 gen = GenAbout ()
568575
576+ dup_keys = gen .get_duplicated_keys (input_path )
577+ if dup_keys :
578+ print ('The input file contains duplicated keys. Duplicated keys are not allowed.' )
579+ print (dup_keys )
580+ print ('\n Please fix the input file and re-run the tool.' )
581+ sys .exit (errno .EINVAL )
582+
569583 # Clear the log file
570584 with open (output_path + LOG_FILENAME , 'w' ):
571585 pass
0 commit comments