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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/features_utility.py
diff --git a/chrome/common/extensions/docs/server2/features_utility.py b/chrome/common/extensions/docs/server2/features_utility.py
new file mode 100644
index 0000000000000000000000000000000000000000..8af0b7ba1ce08c7a47caaa910b35de49ef6c0faf
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/features_utility.py
@@ -0,0 +1,47 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+def ProcessFeaturesFile(features_json):
+ '''Standardize a features file dictionary by ignoring whitelisted entries,
+ thus also reducing keys with lists as values into simple dictionaries.
+ Returns the standardized dictionary.
+ '''
+ master_dict = {}
+
+ for name, value in features_json.iteritems():
+ if isinstance(value, list):
+ temp = None
+ for subvalue in value:
+ if not 'whitelist' in subvalue:
+ temp = subvalue
+ break
+ else:
+ # Ignore this entry in the features file.
+ continue
+ value = temp
+
+ if 'whitelist' in value:
+ continue
+ master_dict[name] = { 'platform': [] }
+
+ platforms = value.pop('extension_types')
+ if platforms == 'all' or 'extension' in platforms:
+ master_dict[name]['platform'].append('extension')
+ if platforms == 'all' or 'platform_app' in platforms:
+ master_dict[name]['platform'].append('app')
+
+ master_dict[name]['name'] = name
+ master_dict[name].update(value)
+
+ return master_dict
+
+def MergeDictionaries(dest, addition):
+ '''Do an in place dictionary merge and combine sub dictionaries with a
+ standard merge.
+ '''
+ for key, value in addition.iteritems():
+ if key in dest:
+ dest[key].update(value)
+ else:
+ 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.

Powered by Google App Engine
This is Rietveld 408576698