|
60 | 60 | from attributecode import util |
61 | 61 | from attributecode.util import add_unc |
62 | 62 | from attributecode.util import copy_license_notice_files |
| 63 | +from attributecode.util import check_duplicate_keys_about_file |
63 | 64 | from attributecode.util import on_windows |
64 | 65 | from attributecode.util import UNC_PREFIX |
65 | 66 | from attributecode.util import UNC_PREFIX_POSIX |
@@ -983,18 +984,23 @@ def load(self, location, use_mapping=False, mapping_file=None): |
983 | 984 | loc = add_unc(loc) |
984 | 985 | with codecs.open(loc, encoding='utf-8') as txt: |
985 | 986 | input_text = txt.read() |
986 | | - """ |
987 | | - The running_inventory defines if the current process is 'inventory' or not. |
988 | | - This is used for the validation of the about_resource_path. |
989 | | - In the 'inventory' command, the code will use the parent of the about_file_path |
990 | | - location and join with the 'about_resource_path' for the validation. |
991 | | - On the other hand, in the 'gen' command, the code will use the |
992 | | - generated location (aka base_dir) along with the parent of the about_file_path |
993 | | - and then join with the 'about_resource_path' |
994 | | - """ |
995 | | - running_inventory = True |
996 | | - errs = self.load_dict(saneyaml.load(input_text), base_dir, running_inventory, use_mapping, mapping_file) |
997 | | - errors.extend(errs) |
| 987 | + dup_keys = check_duplicate_keys_about_file(input_text) |
| 988 | + if dup_keys: |
| 989 | + msg = ('Duplicated key name(s): %(dup_keys)s' % locals()) |
| 990 | + errors.append(Error(ERROR, msg % locals())) |
| 991 | + else: |
| 992 | + """ |
| 993 | + The running_inventory defines if the current process is 'inventory' or not. |
| 994 | + This is used for the validation of the about_resource_path. |
| 995 | + In the 'inventory' command, the code will use the parent of the about_file_path |
| 996 | + location and join with the 'about_resource_path' for the validation. |
| 997 | + On the other hand, in the 'gen' command, the code will use the |
| 998 | + generated location (aka base_dir) along with the parent of the about_file_path |
| 999 | + and then join with the 'about_resource_path' |
| 1000 | + """ |
| 1001 | + running_inventory = True |
| 1002 | + errs = self.load_dict(saneyaml.load(input_text), base_dir, running_inventory, use_mapping, mapping_file) |
| 1003 | + errors.extend(errs) |
998 | 1004 | except Exception as e: |
999 | 1005 | msg = 'Cannot load invalid ABOUT file: %(location)r: %(e)r\n' + str(e) |
1000 | 1006 | errors.append(Error(CRITICAL, msg % locals())) |
|
0 commit comments