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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2014 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 from path_util import AssertIsValid
6
7
8 _EXTENSION_TYPES = {'extensions': 'extension', 'apps': 'platform_app'}
9
10
11 def GetPlatforms():
12 return ('apps', 'extensions')
13
14
15 def GetExtensionTypes():
16 return ('platform_app', 'extension')
17
18
19 def ExtractPlatformFromURL(url):
20 '''Returns 'apps' or 'extensions' depending on the URL.
21 '''
22 AssertIsValid(url)
23 platform = url.split('/', 1)[0]
24 if platform not in GetPlatforms():
25 return None
26 return platform
27
28
29 def PluralToSingular(platform):
30 '''Converts 'apps' to 'app' and 'extensions' to 'extension'.
31 '''
32 assert platform in GetPlatforms(), platform
33 return platform[:-1]
34
35
36 def PlatformToExtensionType(platform):
37 assert platform in GetPlatforms(), platform
38 return _EXTENSION_TYPES[platform]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698