OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import os.path | 5 import os.path |
6 | 6 |
7 from json_parse import OrderedDict | 7 from json_parse import OrderedDict |
8 from memoize import memoize | 8 from memoize import memoize |
9 | 9 |
10 class ParseException(Exception): | 10 class ParseException(Exception): |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
479 class Platforms(object): | 479 class Platforms(object): |
480 """Enum of the possible platforms. | 480 """Enum of the possible platforms. |
481 """ | 481 """ |
482 CHROMEOS = _PlatformInfo("chromeos") | 482 CHROMEOS = _PlatformInfo("chromeos") |
483 CHROMEOS_TOUCH = _PlatformInfo("chromeos_touch") | 483 CHROMEOS_TOUCH = _PlatformInfo("chromeos_touch") |
484 LINUX = _PlatformInfo("linux") | 484 LINUX = _PlatformInfo("linux") |
485 MAC = _PlatformInfo("mac") | 485 MAC = _PlatformInfo("mac") |
486 WIN = _PlatformInfo("win") | 486 WIN = _PlatformInfo("win") |
487 | 487 |
488 def _GetPlatforms(json): | 488 def _GetPlatforms(json): |
489 if 'platforms' not in json: | 489 if 'platforms' not in json or json['platforms'] == None: |
490 return None | 490 return None |
491 # Check whether "platforms" is an empty list. | |
not at google - send to devlin
2013/10/29 14:36:52
More accurate would be to say "Sanity check: platf
Haojian Wu
2013/10/30 00:42:47
Done.
| |
492 if not json['platforms']: | |
493 raise ValueError('"platforms" cannot be an empty list') | |
491 platforms = [] | 494 platforms = [] |
492 for platform_name in json['platforms']: | 495 for platform_name in json['platforms']: |
493 for platform_enum in _Enum.GetAll(Platforms): | 496 for platform_enum in _Enum.GetAll(Platforms): |
494 if platform_name == platform_enum.name: | 497 if platform_name == platform_enum.name: |
495 platforms.append(platform_enum) | 498 platforms.append(platform_enum) |
496 break | 499 break |
497 return platforms | 500 return platforms |
OLD | NEW |