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 import os | 5 import os |
6 import sys | 6 import sys |
7 | 7 |
8 | 8 |
9 def _add_ext_dirs_to_path(): | 9 def _add_ext_dirs_to_path(): |
10 base = os.path.dirname(os.path.abspath(__file__)) | 10 base = os.path.dirname(os.path.abspath(__file__)) |
11 | 11 |
12 for d in os.listdir(base): | 12 for d in os.listdir(base): |
13 full = os.path.join(base, d) | 13 full = os.path.join(base, d) |
14 if os.path.isdir(full): | 14 if os.path.isdir(full): |
15 # TODO(iannucci): look for egg | 15 # TODO(iannucci): look for egg |
16 sys.path.insert(0, full) | 16 sys.path.insert(0, full) |
17 globals()[d] = __import__(d) | 17 globals()[d] = __import__(d) |
18 | 18 |
19 _add_ext_dirs_to_path() | 19 _add_ext_dirs_to_path() |
20 | 20 |
21 # Enough of a hint for pylint / jedi (autocompletion) to find and follow the | 21 # Enough of a hint for pylint / jedi (autocompletion) to find and follow the |
22 # imports, but doesn't make python import them immediately at runtime. | 22 # imports, but doesn't make python import them immediately at runtime. |
23 # | 23 # |
24 # This list should always contain a complete list of all modules in ext. | 24 # This list should always contain a complete list of all modules in ext. |
25 if False: | 25 if False: |
26 import argcomplete | 26 import argcomplete |
Vadim Sh.
2014/06/30 17:24:12
btw, you use yaml. Is pyyaml in ext?
iannucci
2014/06/30 23:03:03
No not yet :(. I want to add it, but there are too
| |
27 import dateutil | 27 import dateutil |
28 import httplib2 | 28 import httplib2 |
29 import oauth2client | 29 import oauth2client |
30 import pytz | 30 import pytz |
31 import requests | 31 import requests |
32 import testing_support | 32 import testing_support |
33 | 33 |
34 | 34 |
35 class _LazyImportHack(object): | 35 class _LazyImportHack(object): |
36 __path__ = [] | |
36 | 37 |
37 def __getattr__(self, name): | 38 def __getattr__(self, name): |
38 mod = __import__(name) | 39 mod = __import__(name) |
39 setattr(self, name, mod) | 40 setattr(self, name, mod) |
40 return mod | 41 return mod |
41 | 42 |
42 sys.modules[__name__] = _LazyImportHack() | 43 sys.modules[__name__] = _LazyImportHack() |
OLD | NEW |