Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 def ProcessFeaturesFile(features_json): | |
| 6 '''Standardize a features file dictionary by ignoring whitelisted entries, | |
| 7 thus also reducing keys with lists as values into simple dictionaries. | |
| 8 Returns the standardized dictionary. | |
| 9 ''' | |
| 10 master_dict = {} | |
| 11 | |
| 12 for name, value in features_json.iteritems(): | |
| 13 if isinstance(value, list): | |
| 14 temp = None | |
| 15 for subvalue in value: | |
| 16 if not 'whitelist' in subvalue: | |
| 17 temp = subvalue | |
| 18 break | |
| 19 else: | |
| 20 # Ignore this entry in the features file. | |
| 21 continue | |
| 22 value = temp | |
| 23 | |
| 24 if 'whitelist' in value: | |
| 25 continue | |
| 26 master_dict[name] = { 'platform': [] } | |
| 27 | |
| 28 platforms = value.pop('extension_types') | |
| 29 if platforms == 'all' or 'extension' in platforms: | |
| 30 master_dict[name]['platform'].append('extension') | |
| 31 if platforms == 'all' or 'platform_app' in platforms: | |
| 32 master_dict[name]['platform'].append('app') | |
| 33 | |
| 34 master_dict[name]['name'] = name | |
| 35 master_dict[name].update(value) | |
| 36 | |
| 37 return master_dict | |
| 38 | |
| 39 def MergeDictionaries(dest, addition): | |
| 40 '''Do an in place dictionary merge and combine sub dictionaries with a | |
| 41 standard merge. | |
| 42 ''' | |
| 43 for key, value in addition.iteritems(): | |
| 44 if key in dest: | |
| 45 dest[key].update(value) | |
| 46 else: | |
| 47 dest[key] = value | |
|
not at google - send to devlin
2013/07/24 21:45:56
I would rather there were all OO. Create an abstra
jshumway
2013/07/26 00:36:46
Did my best to 'OOify' it.
| |
| OLD | NEW |