Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 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 | 5 |
| 6 """Miscellaneous utilities needed by the Skia buildbot master.""" | 6 """Miscellaneous utilities needed by the Skia buildbot master.""" |
| 7 | 7 |
| 8 | 8 |
| 9 import httplib2 | 9 import httplib2 |
| 10 import re | 10 import re |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 TRYBOT_NAME_SUFFIX = '_Trybot' | 38 TRYBOT_NAME_SUFFIX = '_Trybot' |
| 39 TRY_SCHEDULER_SVN = 'skia_try_svn' | 39 TRY_SCHEDULER_SVN = 'skia_try_svn' |
| 40 TRY_SCHEDULER_RIETVELD = 'skia_try_rietveld' | 40 TRY_SCHEDULER_RIETVELD = 'skia_try_rietveld' |
| 41 TRY_SCHEDULERS = [TRY_SCHEDULER_SVN, TRY_SCHEDULER_RIETVELD] | 41 TRY_SCHEDULERS = [TRY_SCHEDULER_SVN, TRY_SCHEDULER_RIETVELD] |
| 42 TRY_SCHEDULERS_STR = '|'.join(TRY_SCHEDULERS) | 42 TRY_SCHEDULERS_STR = '|'.join(TRY_SCHEDULERS) |
| 43 | 43 |
| 44 | 44 |
| 45 def IsTrybot(builder_name): | 45 def IsTrybot(builder_name): |
| 46 return builder_name.endswith(TRYBOT_NAME_SUFFIX) | 46 return builder_name.endswith(TRYBOT_NAME_SUFFIX) |
| 47 | 47 |
| 48 | 48 |
|
borenet
2013/04/25 15:50:28
Helpers for dumping out the dictionary. We need t
| |
| 49 def IndentStr(indent): | |
|
rmistry
2013/04/25 17:31:50
private function?
The only one that looks useful h
borenet
2013/04/25 18:28:09
Done.
| |
| 50 string = '' | |
| 51 for _ in range(indent + 1): | |
| 52 string += ' ' | |
| 53 return string | |
| 54 | |
| 55 | |
| 56 def ToString(o, indent=0): | |
|
rmistry
2013/04/25 17:31:50
If this is going to be the only public function le
borenet
2013/04/25 18:28:09
Done.
| |
| 57 if isinstance(o, list): | |
| 58 return ListToString(o, indent) | |
| 59 elif isinstance(o, dict): | |
| 60 return DictToString(o, indent) | |
| 61 elif isinstance(o, tuple): | |
| 62 return ListToString(o, indent) | |
| 63 elif isinstance(o, str): | |
| 64 return '\'%s\'' % o | |
| 65 elif o is None: | |
| 66 return 'None' | |
| 67 else: | |
| 68 return '<Object>' | |
| 69 | |
| 70 | |
| 71 def ListToString(l, indent): | |
|
rmistry
2013/04/25 17:31:50
private function?
borenet
2013/04/25 18:28:09
Done.
| |
| 72 if not l: | |
| 73 return '[]' | |
| 74 indent_str = IndentStr(indent) | |
| 75 val = '[\n' | |
| 76 indent += 1 | |
| 77 val += ''.join(['%s%s,\n' % (indent_str, ToString(elem, indent)) \ | |
| 78 for elem in l]) | |
| 79 indent -= 1 | |
| 80 indent_str = IndentStr(indent - 1) | |
| 81 val += indent_str + ']' | |
| 82 return val | |
| 83 | |
| 84 | |
| 85 def DictToString(d, indent): | |
|
rmistry
2013/04/25 17:31:50
private function?
borenet
2013/04/25 18:28:09
Done.
| |
| 86 if not d: | |
| 87 return '{}' | |
| 88 indent_str = IndentStr(indent) | |
| 89 val = '{\n' | |
| 90 indent += 1 | |
| 91 val += ''.join(['%s%s: %s,\n' % (indent_str, ToString(k, indent), | |
| 92 ToString(d[k], indent)) \ | |
| 93 for k in sorted(d.keys())]) | |
| 94 indent -= 1 | |
| 95 indent_str = IndentStr(indent - 1) | |
| 96 val += indent_str + '}' | |
| 97 return val | |
| 98 | |
| 99 | |
| 49 class SkiaChangeFilter(ChangeFilter): | 100 class SkiaChangeFilter(ChangeFilter): |
| 50 """Skia specific subclass of ChangeFilter.""" | 101 """Skia specific subclass of ChangeFilter.""" |
| 51 | 102 |
| 52 def __init__(self, builders, **kwargs): | 103 def __init__(self, builders, **kwargs): |
| 53 self._builders = builders | 104 self._builders = builders |
| 54 ChangeFilter.__init__(self, **kwargs) | 105 ChangeFilter.__init__(self, **kwargs) |
| 55 | 106 |
| 56 def filter_change(self, change): | 107 def filter_change(self, change): |
| 57 """Overrides ChangeFilter.filter_change to pass builders to filter_fn. | 108 """Overrides ChangeFilter.filter_change to pass builders to filter_fn. |
| 58 | 109 |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 614 # request is associated with a change but the revisions match (#5 above). | 665 # request is associated with a change but the revisions match (#5 above). |
| 615 if req1.source.changes and not req2.source.changes: | 666 if req1.source.changes and not req2.source.changes: |
| 616 return False | 667 return False |
| 617 if not req1.source.changes and req2.source.changes: | 668 if not req1.source.changes and req2.source.changes: |
| 618 return False | 669 return False |
| 619 if not (req1.source.changes and req2.source.changes): | 670 if not (req1.source.changes and req2.source.changes): |
| 620 if req1.source.revision != req2.source.revision: | 671 if req1.source.revision != req2.source.revision: |
| 621 return False | 672 return False |
| 622 | 673 |
| 623 return True | 674 return True |
| OLD | NEW |