| OLD | NEW |
| 1 # Copyright 2012 Benjamin Kalman | 1 # Copyright 2012 Benjamin Kalman |
| 2 # | 2 # |
| 3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
| 5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
| 6 # | 6 # |
| 7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 # | 8 # |
| 9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
| 10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 continue | 75 continue |
| 76 resolved = self._resolveFrom(context) | 76 resolved = self._resolveFrom(context) |
| 77 if resolved: | 77 if resolved: |
| 78 return resolved | 78 return resolved |
| 79 _RenderError(errors, "Couldn't resolve identifier ", self.path, " in ", cont
exts) | 79 _RenderError(errors, "Couldn't resolve identifier ", self.path, " in ", cont
exts) |
| 80 return None | 80 return None |
| 81 | 81 |
| 82 def _resolveFrom(self, context): | 82 def _resolveFrom(self, context): |
| 83 result = context | 83 result = context |
| 84 for next in self.path: | 84 for next in self.path: |
| 85 if not result or type(result) != dict: | 85 if not result or not getattr(result, "get", None): |
| 86 return None | 86 return None |
| 87 result = result.get(next) | 87 result = result.get(next) |
| 88 return result | 88 return result |
| 89 | 89 |
| 90 def __str__(self): | 90 def __str__(self): |
| 91 return '.'.join(self.path) | 91 return '.'.join(self.path) |
| 92 | 92 |
| 93 class ThisIdentifier(object): | 93 class ThisIdentifier(object): |
| 94 """ An identifier of the form "@". | 94 """ An identifier of the form "@". |
| 95 """ | 95 """ |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 for node in nodes: | 452 for node in nodes: |
| 453 node.render(buf, contexts, errors) | 453 node.render(buf, contexts, errors) |
| 454 | 454 |
| 455 def _RenderError(errors, *messages): | 455 def _RenderError(errors, *messages): |
| 456 if not errors: | 456 if not errors: |
| 457 return | 457 return |
| 458 buf = StringBuilder() | 458 buf = StringBuilder() |
| 459 for message in messages: | 459 for message in messages: |
| 460 buf.append(message) | 460 buf.append(message) |
| 461 errors.append(buf.toString()) | 461 errors.append(buf.toString()) |
| OLD | NEW |