Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 if '=' in line: | 125 if '=' in line: |
| 126 name, value = line.split('=') | 126 name, value = line.split('=') |
| 127 else: | 127 else: |
| 128 name, value = line, True | 128 name, value = line, True |
| 129 if not name in self.parameters: | 129 if not name in self.parameters: |
| 130 self._fatal("Unknown parameter: '%s' in line:\n%s\nKnown parameters: %s" % (name, line, self.parameters.keys())) | 130 self._fatal("Unknown parameter: '%s' in line:\n%s\nKnown parameters: %s" % (name, line, self.parameters.keys())) |
| 131 self.parameters[name] = value | 131 self.parameters[name] = value |
| 132 | 132 |
| 133 def _parse_line(self, line): | 133 def _parse_line(self, line): |
| 134 args = copy.deepcopy(self._defaults) | 134 args = copy.deepcopy(self._defaults) |
| 135 line = line.split('//')[0] # remove comments | |
|
haraken
2014/11/24 09:38:49
I'm not sure but we might want to use '#' instead
philipj_slow
2014/11/24 10:44:59
Also, isn't there already some code for handling /
| |
| 135 parts = line.split(' ') | 136 parts = line.split(' ') |
| 136 args['name'] = parts[0] | 137 args['name'] = parts[0] |
| 137 # re-join the rest of the line and split on ',' | 138 # re-join the rest of the line and split on ',' |
| 138 args_list = ' '.join(parts[1:]).strip().split(',') | 139 args_list = ' '.join(parts[1:]).strip().split(',') |
| 139 for arg_string in args_list: | 140 for arg_string in args_list: |
| 140 arg_string = arg_string.strip() | 141 arg_string = arg_string.strip() |
| 141 if not arg_string: # Ignore empty args | 142 if not arg_string: # Ignore empty args |
| 142 continue | 143 continue |
| 143 if '=' in arg_string: | 144 if '=' in arg_string: |
| 144 arg_name, arg_value = arg_string.split('=') | 145 arg_name, arg_value = arg_string.split('=') |
| 145 else: | 146 else: |
| 146 arg_name, arg_value = arg_string, True | 147 arg_name, arg_value = arg_string, True |
| 147 if arg_name not in self._defaults: | 148 if arg_name not in self._defaults: |
| 148 self._fatal("Unknown argument: '%s' in line:\n%s\nKnown argument s: %s" % (arg_name, line, self._defaults.keys())) | 149 self._fatal("Unknown argument: '%s' in line:\n%s\nKnown argument s: %s" % (arg_name, line, self._defaults.keys())) |
| 149 valid_values = self._valid_values.get(arg_name) | 150 valid_values = self._valid_values.get(arg_name) |
| 150 if valid_values and arg_value not in valid_values: | 151 if valid_values and arg_value not in valid_values: |
| 151 self._fatal("Unknown value: '%s' in line:\n%s\nKnown values: %s" % (arg_value, line, valid_values)) | 152 self._fatal("Unknown value: '%s' in line:\n%s\nKnown values: %s" % (arg_value, line, valid_values)) |
| 152 if self._is_sequence(args[arg_name]): | 153 if self._is_sequence(args[arg_name]): |
| 153 args[arg_name].append(arg_value) | 154 args[arg_name].append(arg_value) |
| 154 else: | 155 else: |
| 155 args[arg_name] = arg_value | 156 args[arg_name] = arg_value |
| 156 return args | 157 return args |
| 157 | 158 |
| 158 def _fatal(self, message): | 159 def _fatal(self, message): |
| 159 # FIXME: This should probably raise instead of exit(1) | 160 # FIXME: This should probably raise instead of exit(1) |
| 160 print message | 161 print message |
| 161 exit(1) | 162 exit(1) |
| OLD | NEW |