| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 """ | 3 """ |
| 4 Copyright 2014 Google Inc. | 4 Copyright 2014 Google Inc. |
| 5 | 5 |
| 6 Use of this source code is governed by a BSD-style license that can be | 6 Use of this source code is governed by a BSD-style license that can be |
| 7 found in the LICENSE file. | 7 found in the LICENSE file. |
| 8 | 8 |
| 9 ImagePairSet class; see its docstring below. | 9 ImagePairSet class; see its docstring below. |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 # System-level imports | 12 # System-level imports |
| 13 import posixpath | 13 import posixpath |
| 14 | 14 |
| 15 # Local imports | 15 # Must fix up PYTHONPATH before importing from within Skia |
| 16 import fix_pythonpath # pylint: disable=W0611 |
| 17 |
| 18 # Imports from within Skia |
| 16 import column | 19 import column |
| 17 import imagediffdb | 20 import imagediffdb |
| 21 from py.utils import gs_utils |
| 18 | 22 |
| 19 # Keys used within dictionary representation of ImagePairSet. | 23 # Keys used within dictionary representation of ImagePairSet. |
| 20 # NOTE: Keep these in sync with static/constants.js | 24 # NOTE: Keep these in sync with static/constants.js |
| 21 KEY__ROOT__EXTRACOLUMNHEADERS = 'extraColumnHeaders' | 25 KEY__ROOT__EXTRACOLUMNHEADERS = 'extraColumnHeaders' |
| 22 KEY__ROOT__EXTRACOLUMNORDER = 'extraColumnOrder' | 26 KEY__ROOT__EXTRACOLUMNORDER = 'extraColumnOrder' |
| 23 KEY__ROOT__HEADER = 'header' | 27 KEY__ROOT__HEADER = 'header' |
| 24 KEY__ROOT__IMAGEPAIRS = 'imagePairs' | 28 KEY__ROOT__IMAGEPAIRS = 'imagePairs' |
| 25 KEY__ROOT__IMAGESETS = 'imageSets' | 29 KEY__ROOT__IMAGESETS = 'imageSets' |
| 26 KEY__IMAGESETS__FIELD__BASE_URL = 'baseUrl' | 30 KEY__IMAGESETS__FIELD__BASE_URL = 'baseUrl' |
| 27 KEY__IMAGESETS__FIELD__DESCRIPTION = 'description' | 31 KEY__IMAGESETS__FIELD__DESCRIPTION = 'description' |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 specified_column_ids = set(column_ids_in_order) | 159 specified_column_ids = set(column_ids_in_order) |
| 156 forgotten_column_ids = all_column_ids - specified_column_ids | 160 forgotten_column_ids = all_column_ids - specified_column_ids |
| 157 assert not forgotten_column_ids, ( | 161 assert not forgotten_column_ids, ( |
| 158 'column_ids_in_order %s missing these column_ids: %s' % ( | 162 'column_ids_in_order %s missing these column_ids: %s' % ( |
| 159 column_ids_in_order, forgotten_column_ids)) | 163 column_ids_in_order, forgotten_column_ids)) |
| 160 column_ids_in_order = [c for c in column_ids_in_order | 164 column_ids_in_order = [c for c in column_ids_in_order |
| 161 if c in all_column_ids] | 165 if c in all_column_ids] |
| 162 | 166 |
| 163 key_description = KEY__IMAGESETS__FIELD__DESCRIPTION | 167 key_description = KEY__IMAGESETS__FIELD__DESCRIPTION |
| 164 key_base_url = KEY__IMAGESETS__FIELD__BASE_URL | 168 key_base_url = KEY__IMAGESETS__FIELD__BASE_URL |
| 169 # EPOGER: instead of this special handling for GS URLs vs HTTP URLs, maybe c
ome up with an object than can represent either one? (or even a local file) |
| 170 if gs_utils.GSUtils.is_gs_url(self._image_base_url): |
| 171 value_base_url = imagediffdb.GSObject( |
| 172 gs_url=self._image_base_url).as_http_url() |
| 173 else: |
| 174 value_base_url = self._image_base_url |
| 175 |
| 165 return { | 176 return { |
| 166 KEY__ROOT__EXTRACOLUMNHEADERS: self._column_headers_as_dict(), | 177 KEY__ROOT__EXTRACOLUMNHEADERS: self._column_headers_as_dict(), |
| 167 KEY__ROOT__EXTRACOLUMNORDER: column_ids_in_order, | 178 KEY__ROOT__EXTRACOLUMNORDER: column_ids_in_order, |
| 168 KEY__ROOT__IMAGEPAIRS: self._image_pair_dicts, | 179 KEY__ROOT__IMAGEPAIRS: self._image_pair_dicts, |
| 169 KEY__ROOT__IMAGESETS: { | 180 KEY__ROOT__IMAGESETS: { |
| 170 KEY__IMAGESETS__SET__IMAGE_A: { | 181 KEY__IMAGESETS__SET__IMAGE_A: { |
| 171 key_description: self._descriptions[0], | 182 key_description: self._descriptions[0], |
| 172 key_base_url: self._image_base_url, | 183 key_base_url: value_base_url, |
| 173 }, | 184 }, |
| 174 KEY__IMAGESETS__SET__IMAGE_B: { | 185 KEY__IMAGESETS__SET__IMAGE_B: { |
| 175 key_description: self._descriptions[1], | 186 key_description: self._descriptions[1], |
| 176 key_base_url: self._image_base_url, | 187 key_base_url: value_base_url, |
| 177 }, | 188 }, |
| 178 KEY__IMAGESETS__SET__DIFFS: { | 189 KEY__IMAGESETS__SET__DIFFS: { |
| 179 key_description: 'color difference per channel', | 190 key_description: 'color difference per channel', |
| 180 key_base_url: posixpath.join( | 191 key_base_url: posixpath.join( |
| 181 self._diff_base_url, imagediffdb.RGBDIFFS_SUBDIR), | 192 self._diff_base_url, imagediffdb.RGBDIFFS_SUBDIR), |
| 182 }, | 193 }, |
| 183 KEY__IMAGESETS__SET__WHITEDIFFS: { | 194 KEY__IMAGESETS__SET__WHITEDIFFS: { |
| 184 key_description: 'differing pixels in white', | 195 key_description: 'differing pixels in white', |
| 185 key_base_url: posixpath.join( | 196 key_base_url: posixpath.join( |
| 186 self._diff_base_url, imagediffdb.WHITEDIFFS_SUBDIR), | 197 self._diff_base_url, imagediffdb.WHITEDIFFS_SUBDIR), |
| 187 }, | 198 }, |
| 188 }, | 199 }, |
| 189 } | 200 } |
| OLD | NEW |