| OLD | NEW |
| (Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import sys |
| 6 |
| 7 # App Engine source file imports must be relative to their app's root. |
| 8 # Provide a way to mangle sys.path, but not leave it littered with junk. |
| 9 |
| 10 # TODO(ojan): This is a stopgap. Come up with a more general solution. |
| 11 |
| 12 # pylint: disable=W0702 |
| 13 |
| 14 class PathMangler: # pragma: no cover |
| 15 def __init__(self, root): |
| 16 self.app_root = root |
| 17 |
| 18 def __enter__(self): |
| 19 sys.path.append(self.app_root) |
| 20 |
| 21 try: |
| 22 import model |
| 23 reload(model) |
| 24 except: |
| 25 pass |
| 26 |
| 27 try: |
| 28 import handlers |
| 29 reload(handlers) |
| 30 except: |
| 31 pass |
| 32 |
| 33 def __exit__(self, etype, value, etraceback): |
| 34 sys.path.remove(self.app_root) |
| OLD | NEW |