| 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 """Helper functions useful when writing scripts that integrate with GN. | 5 """Helper functions useful when writing scripts that integrate with GN. |
| 6 | 6 |
| 7 The main functions are ToGNString and FromGNString which convert between | 7 The main functions are ToGNString and FromGNString which convert between |
| 8 serialized GN veriables and Python variables. | 8 serialized GN veriables and Python variables. |
| 9 | 9 |
| 10 To use in a random python file in the build: | 10 To use in a random python file in the build: |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 self.ConsumeWhitespace() | 273 self.ConsumeWhitespace() |
| 274 | 274 |
| 275 raise GNException("Unterminated list:\n " + self.input) | 275 raise GNException("Unterminated list:\n " + self.input) |
| 276 | 276 |
| 277 def _ConstantFollows(self, constant): | 277 def _ConstantFollows(self, constant): |
| 278 """Returns true if the given constant follows immediately at the current | 278 """Returns true if the given constant follows immediately at the current |
| 279 location in the input. If it does, the text is consumed and the function | 279 location in the input. If it does, the text is consumed and the function |
| 280 returns true. Otherwise, returns false and the current position is | 280 returns true. Otherwise, returns false and the current position is |
| 281 unchanged.""" | 281 unchanged.""" |
| 282 end = self.cur + len(constant) | 282 end = self.cur + len(constant) |
| 283 if end >= len(self.input): | 283 if end > len(self.input): |
| 284 return False # Not enough room. | 284 return False # Not enough room. |
| 285 if self.input[self.cur:end] == constant: | 285 if self.input[self.cur:end] == constant: |
| 286 self.cur = end | 286 self.cur = end |
| 287 return True | 287 return True |
| 288 return False | 288 return False |
| OLD | NEW |