OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # coding: utf-8 | 2 # coding: utf-8 |
3 | 3 |
4 # This Source Code Form is subject to the terms of the Mozilla Public | 4 # This Source Code Form is subject to the terms of the Mozilla Public |
5 # License, v. 2.0. If a copy of the MPL was not distributed with this | 5 # License, v. 2.0. If a copy of the MPL was not distributed with this |
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 6 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
7 | 7 |
8 import sys | 8 import sys |
9 import os | 9 import os |
10 import posixpath | 10 import posixpath |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 if spec: | 160 if spec: |
161 result[key] = spec | 161 result[key] = spec |
162 return result | 162 return result |
163 except IOError, e: | 163 except IOError, e: |
164 if e.errno != errno.ENOENT: | 164 if e.errno != errno.ENOENT: |
165 raise | 165 raise |
166 return None | 166 return None |
167 | 167 |
168 def safe_join(path, subpath): | 168 def safe_join(path, subpath): |
169 # This has been inspired by Flask's safe_join() function | 169 # This has been inspired by Flask's safe_join() function |
170 forbidden = set([os.sep, os.altsep]) - set([posixpath.sep, None]) | 170 forbidden = {os.sep, os.altsep} - {posixpath.sep, None} |
171 if any(sep in subpath for sep in forbidden): | 171 if any(sep in subpath for sep in forbidden): |
172 raise Exception("Illegal directory separator in dependency path %s" % subpat
h) | 172 raise Exception("Illegal directory separator in dependency path %s" % subpat
h) |
173 | 173 |
174 normpath = posixpath.normpath(subpath) | 174 normpath = posixpath.normpath(subpath) |
175 if posixpath.isabs(normpath): | 175 if posixpath.isabs(normpath): |
176 raise Exception("Dependency path %s cannot be absolute" % subpath) | 176 raise Exception("Dependency path %s cannot be absolute" % subpath) |
177 if normpath == posixpath.pardir or normpath.startswith(posixpath.pardir + posi
xpath.sep): | 177 if normpath == posixpath.pardir or normpath.startswith(posixpath.pardir + posi
xpath.sep): |
178 raise Exception("Dependency path %s has to be inside the repository" % subpa
th) | 178 raise Exception("Dependency path %s has to be inside the repository" % subpa
th) |
179 return os.path.join(path, *normpath.split(posixpath.sep)) | 179 return os.path.join(path, *normpath.split(posixpath.sep)) |
180 | 180 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 args = parser.parse_args() | 303 args = parser.parse_args() |
304 | 304 |
305 if args.quiet: | 305 if args.quiet: |
306 logging.disable(logging.INFO) | 306 logging.disable(logging.INFO) |
307 | 307 |
308 repos = args.repos | 308 repos = args.repos |
309 if not len(repos): | 309 if not len(repos): |
310 repos = [os.path.dirname(__file__)] | 310 repos = [os.path.dirname(__file__)] |
311 for repo in repos: | 311 for repo in repos: |
312 resolve_deps(repo) | 312 resolve_deps(repo) |
OLD | NEW |