| OLD | NEW |
| 1 #!/usr/bin/env python2 | 1 #!/usr/bin/env python2 |
| 2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
| 3 | 3 |
| 4 # Copyright 2016 Google Inc. All Rights Reserved. | 4 # Copyright 2016 Google Inc. All Rights Reserved. |
| 5 # | 5 # |
| 6 # Licensed under the Apache License, Version 2.0 (the "License"); | 6 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 # you may not use this file except in compliance with the License. | 7 # you may not use this file except in compliance with the License. |
| 8 # You may obtain a copy of the License at | 8 # You may obtain a copy of the License at |
| 9 # | 9 # |
| 10 # http://www.apache.org/licenses/LICENSE-2.0 | 10 # http://www.apache.org/licenses/LICENSE-2.0 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 process_usage(missing_apis, usage) | 187 process_usage(missing_apis, usage) |
| 188 | 188 |
| 189 return templates.TEMPLATE_NOT_POLYFILLED.render( | 189 return templates.TEMPLATE_NOT_POLYFILLED.render( |
| 190 some_not_polyfilled=bool(missing_apis), | 190 some_not_polyfilled=bool(missing_apis), |
| 191 apis=missing_apis, | 191 apis=missing_apis, |
| 192 ca_manifest=ca_manifest, | 192 ca_manifest=ca_manifest, |
| 193 Status=Status | 193 Status=Status |
| 194 ) | 194 ) |
| 195 | 195 |
| 196 | 196 |
| 197 def make_warning(name, member, text, apis, formatter=None): | 197 def make_warning(name, member, text, apis): |
| 198 """Generates a warning dictionary. | 198 """Generates a warning dictionary. |
| 199 | 199 |
| 200 Args: | 200 Args: |
| 201 name: Name of Chrome Apps API, e.g. tts for chrome.tts | 201 name: Name of Chrome Apps API, e.g. tts for chrome.tts |
| 202 member: Member within Chrome Apps API, e.g. onChanged.addListener for | 202 member: Member within Chrome Apps API, e.g. onChanged.addListener for |
| 203 chrome.storage.onChanged.addListener | 203 chrome.storage.onChanged.addListener |
| 204 text: Text of warning. | 204 text: Text of warning. |
| 205 apis: Dictionary mapping Chrome Apps API name to polyfill manifest | 205 apis: Dictionary mapping Chrome Apps API name to polyfill manifest |
| 206 dictionaries. | 206 dictionaries. |
| 207 formatter: A function to pass the warning text through before returning. | |
| 208 | 207 |
| 209 Returns: | 208 Returns: |
| 210 Warning dictionary of form {'member': member name e.g onChanged.addListener, | 209 Warning dictionary of form {'member': member name e.g onChanged.addListener, |
| 211 'text': warning text}. | 210 'text': warning text}. |
| 212 """ | 211 """ |
| 213 full_text = 'chrome.{}.{}: {}'.format(name, member, text) | 212 full_text = 'chrome.{}.{}: {}'.format(name, member, text) |
| 214 if formatter: | 213 formatted_text = format_html(full_text, apis) |
| 215 formatted_text = formatter(full_text) | |
| 216 else: | |
| 217 formatted_text = format_html(full_text, apis) | |
| 218 | 214 |
| 219 return {'member': member, 'text': formatted_text} | 215 return {'member': member, 'text': formatted_text} |
| 220 | 216 |
| 221 | 217 |
| 222 def manifest_warnings(manifest, apis): | 218 def manifest_warnings(manifest, apis): |
| 223 """Extracts formatted warnings from a polyfill manifest. | 219 """Extracts formatted warnings from a polyfill manifest. |
| 224 | 220 |
| 225 Args: | 221 Args: |
| 226 manifest: Polyfill manifest dictionary. | 222 manifest: Polyfill manifest dictionary. |
| 227 apis: Dictionary mapping Chrome Apps API name to polyfill manifest | 223 apis: Dictionary mapping Chrome Apps API name to polyfill manifest |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 polyfilled = generate_polyfilled(ca_manifest, apis, pwa_path, ignore_dirs) | 333 polyfilled = generate_polyfilled(ca_manifest, apis, pwa_path, ignore_dirs) |
| 338 not_polyfilled = generate_not_polyfilled( | 334 not_polyfilled = generate_not_polyfilled( |
| 339 ca_manifest, apis, pwa_path, ignore_dirs) | 335 ca_manifest, apis, pwa_path, ignore_dirs) |
| 340 return templates.TEMPLATE_FULL.render( | 336 return templates.TEMPLATE_FULL.render( |
| 341 ca_manifest=ca_manifest, | 337 ca_manifest=ca_manifest, |
| 342 summary=summary, | 338 summary=summary, |
| 343 general_warnings=general_warnings, | 339 general_warnings=general_warnings, |
| 344 polyfilled=polyfilled, | 340 polyfilled=polyfilled, |
| 345 not_polyfilled=not_polyfilled | 341 not_polyfilled=not_polyfilled |
| 346 ) | 342 ) |
| OLD | NEW |