OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 '''Base types for nodes in a GRIT resource tree. | 6 '''Base types for nodes in a GRIT resource tree. |
7 ''' | 7 ''' |
8 | 8 |
9 import collections | 9 import collections |
10 import os | 10 import os |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 def pp_ifdef(symbol): | 451 def pp_ifdef(symbol): |
452 return symbol in defs | 452 return symbol in defs |
453 def pp_if(symbol): | 453 def pp_if(symbol): |
454 return defs.get(symbol, False) | 454 return defs.get(symbol, False) |
455 variable_map = { | 455 variable_map = { |
456 'defs' : defs, | 456 'defs' : defs, |
457 'os': target_platform, | 457 'os': target_platform, |
458 'is_linux': target_platform.startswith('linux'), | 458 'is_linux': target_platform.startswith('linux'), |
459 'is_macosx': target_platform == 'darwin', | 459 'is_macosx': target_platform == 'darwin', |
460 'is_win': target_platform in ('cygwin', 'win32'), | 460 'is_win': target_platform in ('cygwin', 'win32'), |
461 'is_posix': (target_platform in ('darwin', 'linux2', 'linux3', 'sunos5') | 461 'is_android': target_platform == 'android', |
462 or 'bsd' in target_platform), | 462 'is_posix': (target_platform in ('darwin', 'linux2', 'linux3', 'sunos5', |
| 463 'android') |
| 464 or 'bsd' in target_platform), |
463 'pp_ifdef' : pp_ifdef, | 465 'pp_ifdef' : pp_ifdef, |
464 'pp_if' : pp_if, | 466 'pp_if' : pp_if, |
465 } | 467 } |
466 if extra_variables: | 468 if extra_variables: |
467 variable_map.update(extra_variables) | 469 variable_map.update(extra_variables) |
468 eval_result = cache_dict[expr] = eval(expr, {}, variable_map) | 470 eval_result = cache_dict[expr] = eval(expr, {}, variable_map) |
469 return eval_result | 471 return eval_result |
470 | 472 |
471 def EvaluateCondition(self, expr): | 473 def EvaluateCondition(self, expr): |
472 '''Returns true if and only if the Python expression 'expr' evaluates | 474 '''Returns true if and only if the Python expression 'expr' evaluates |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 def ExpandVariables(self): | 557 def ExpandVariables(self): |
556 '''Whether we need to expand variables on a given node.''' | 558 '''Whether we need to expand variables on a given node.''' |
557 return False | 559 return False |
558 | 560 |
559 | 561 |
560 class ContentNode(Node): | 562 class ContentNode(Node): |
561 '''Convenience baseclass for nodes that can have content.''' | 563 '''Convenience baseclass for nodes that can have content.''' |
562 def _ContentType(self): | 564 def _ContentType(self): |
563 return self._CONTENT_TYPE_MIXED | 565 return self._CONTENT_TYPE_MIXED |
564 | 566 |
OLD | NEW |