Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """Process Chrome resources (HTML/CSS/JS) to handle <include> and <if> tags.""" | 5 """Process Chrome resources (HTML/CSS/JS) to handle <include> and <if> tags.""" |
| 6 | 6 |
| 7 from collections import defaultdict | 7 from collections import defaultdict |
| 8 import re | 8 import re |
| 9 import os | 9 import os |
| 10 | 10 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 | 66 |
| 67 Args: | 67 Args: |
| 68 source_file: A file to process. | 68 source_file: A file to process. |
| 69 | 69 |
| 70 Attributes: | 70 Attributes: |
| 71 contents: Expanded contents after inlining <include>s and stripping <if>s. | 71 contents: Expanded contents after inlining <include>s and stripping <if>s. |
| 72 included_files: A list of files that were inlined via <include>. | 72 included_files: A list of files that were inlined via <include>. |
| 73 """ | 73 """ |
| 74 | 74 |
| 75 _IF_TAGS_REG = "</?if[^>]*?>" | 75 _IF_TAGS_REG = "</?if[^>]*?>" |
| 76 _INCLUDE_REG = "<include[^>]+src=['\"]([^>]*)['\"]>" | 76 _INCLUDE_REG = "<include[^>]+src=['\"]([^>]*)['\"] ?/?>" |
|
Dan Beam
2014/09/19 21:51:53
remove, https://codereview.chromium.org/588673003
Vitaly Pavlenko
2014/09/19 21:59:33
I added it because there's a lot of such code:
htt
Dan Beam
2014/09/19 22:07:37
not gradually, no: https://codereview.chromium.org
Vitaly Pavlenko
2014/09/19 22:20:17
Ok, reverted my changes.
| |
| 77 | 77 |
| 78 def __init__(self, source_file): | 78 def __init__(self, source_file): |
| 79 self._included_files = set() | 79 self._included_files = set() |
| 80 self._index = 0 | 80 self._index = 0 |
| 81 self._lines = self._get_file(source_file) | 81 self._lines = self._get_file(source_file) |
| 82 | 82 |
| 83 while self._index < len(self._lines): | 83 while self._index < len(self._lines): |
| 84 current_line = self._lines[self._index] | 84 current_line = self._lines[self._index] |
| 85 match = re.search(self._INCLUDE_REG, current_line[2]) | 85 match = re.search(self._INCLUDE_REG, current_line[2]) |
| 86 if match: | 86 if match: |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 110 Args: | 110 Args: |
| 111 line_number: A processed file's line number. | 111 line_number: A processed file's line number. |
| 112 """ | 112 """ |
| 113 line_number = int(line_number) - 1 | 113 line_number = int(line_number) - 1 |
| 114 return LineNumber(self._lines[line_number][0], self._lines[line_number][1]) | 114 return LineNumber(self._lines[line_number][0], self._lines[line_number][1]) |
| 115 | 115 |
| 116 @property | 116 @property |
| 117 def included_files(self): | 117 def included_files(self): |
| 118 """A list of files that were inlined via <include>.""" | 118 """A list of files that were inlined via <include>.""" |
| 119 return self._included_files | 119 return self._included_files |
| OLD | NEW |