OLD | NEW |
(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] |
OLD | NEW |