Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1316)

Side by Side Diff: chrome/common/extensions/docs/server2/features_utility.py

Issue 16410002: Docserver manifest follow up (rewrite) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gen-manifest-try-2
Patch Set: manifest follow up (rewrite) Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698