| 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]
|
|
|