| OLD | NEW |
| 1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 import os | 29 import os |
| 30 import sys | 30 import sys |
| 31 | 31 |
| 32 | 32 |
| 33 def add_typ_dir_to_sys_path(): |
| 34 path_to_typ = get_typ_dir() |
| 35 if path_to_typ not in sys.path: |
| 36 sys.path.append(path_to_typ) |
| 37 |
| 38 |
| 39 def add_bindings_scripts_dir_to_sys_path(): |
| 40 path_to_bindings_scripts = get_bindings_scripts_dir() |
| 41 if path_to_bindings_scripts not in sys.path: |
| 42 sys.path.append(path_to_bindings_scripts) |
| 43 |
| 44 |
| 45 def get_bindings_scripts_dir(): |
| 46 return os.path.join(get_source_dir(), 'bindings', 'scripts') |
| 47 |
| 48 |
| 49 def get_blink_dir(): |
| 50 return os.path.dirname(os.path.dirname(get_scripts_dir())) |
| 51 |
| 52 |
| 53 def get_chromium_src_dir(): |
| 54 return os.path.dirname(os.path.dirname(get_blink_dir())) |
| 55 |
| 56 |
| 57 def get_scripts_dir(): |
| 58 return os.path.dirname( |
| 59 os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) |
| 60 |
| 61 |
| 62 def get_source_dir(): |
| 63 return os.path.join(get_blink_dir(), 'Source') |
| 64 |
| 65 |
| 66 def get_typ_dir(): |
| 67 return os.path.join(get_chromium_src_dir(), 'third_party', 'typ') |
| 68 |
| 69 |
| 70 def get_webkitpy_thirdparty_dir(): |
| 71 return os.path.join(get_scripts_dir(), 'webkitpy', 'thirdparty') |
| 72 |
| 73 |
| 33 class WebKitFinder(object): | 74 class WebKitFinder(object): |
| 34 | 75 |
| 35 def __init__(self, filesystem): | 76 def __init__(self, filesystem): |
| 36 self._filesystem = filesystem | 77 self._filesystem = filesystem |
| 37 self._dirsep = filesystem.sep | 78 self._dirsep = filesystem.sep |
| 38 self._sys_path = sys.path | 79 self._sys_path = sys.path |
| 39 self._env_path = os.environ['PATH'].split(os.pathsep) | 80 self._env_path = os.environ['PATH'].split(os.pathsep) |
| 40 self._webkit_base = None | 81 self._webkit_base = None |
| 41 self._chromium_base = None | 82 self._chromium_base = None |
| 42 self._depot_tools = None | 83 self._depot_tools = None |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 prev_dir = '' | 169 prev_dir = '' |
| 129 current_dir = fs.dirname(self._webkit_base) | 170 current_dir = fs.dirname(self._webkit_base) |
| 130 while current_dir != prev_dir: | 171 while current_dir != prev_dir: |
| 131 if fs.exists(fs.join(current_dir, 'depot_tools', 'pylint.py')): | 172 if fs.exists(fs.join(current_dir, 'depot_tools', 'pylint.py')): |
| 132 return fs.join(current_dir, 'depot_tools') | 173 return fs.join(current_dir, 'depot_tools') |
| 133 prev_dir = current_dir | 174 prev_dir = current_dir |
| 134 current_dir = fs.dirname(current_dir) | 175 current_dir = fs.dirname(current_dir) |
| 135 | 176 |
| 136 def path_from_depot_tools_base(self, *comps): | 177 def path_from_depot_tools_base(self, *comps): |
| 137 return self._filesystem.join(self.depot_tools_base(), *comps) | 178 return self._filesystem.join(self.depot_tools_base(), *comps) |
| OLD | NEW |