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

Unified Diff: chrome/common/extensions/docs/server2/platform_util.py

Issue 344453003: Docserver: separate models for apps and extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase/Add comment Created 6 years, 6 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/platform_util.py
diff --git a/chrome/common/extensions/docs/server2/platform_util.py b/chrome/common/extensions/docs/server2/platform_util.py
new file mode 100644
index 0000000000000000000000000000000000000000..84e8c7480f30b5ce1554cabced4e4f6cb35215d9
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/platform_util.py
@@ -0,0 +1,38 @@
+# Copyright 2014 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.
+
+from path_util import AssertIsValid
+
+
+_EXTENSION_TYPES = {'extensions': 'extension', 'apps': 'platform_app'}
+
+
+def GetPlatforms():
+ return ('apps', 'extensions')
+
+
+def GetExtensionTypes():
+ return ('platform_app', 'extension')
+
+
+def ExtractPlatformFromURL(url):
+ '''Returns 'apps' or 'extensions' depending on the URL.
+ '''
+ AssertIsValid(url)
+ platform = url.split('/', 1)[0]
+ if platform not in GetPlatforms():
+ return None
+ return platform
+
+
+def PluralToSingular(platform):
+ '''Converts 'apps' to 'app' and 'extensions' to 'extension'.
+ '''
+ assert platform in GetPlatforms(), platform
+ return platform[:-1]
+
+
+def PlatformToExtensionType(platform):
+ assert platform in GetPlatforms(), platform
+ return _EXTENSION_TYPES[platform]

Powered by Google App Engine
This is Rietveld 408576698