| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # This Source Code Form is subject to the terms of the Mozilla Public | 3 # This Source Code Form is subject to the terms of the Mozilla Public |
| 4 # License, v. 2.0. If a copy of the MPL was not distributed with this | 4 # License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 6 | 6 |
| 7 import sys | 7 import sys |
| 8 import os | 8 import os |
| 9 import posixpath | 9 import posixpath |
| 10 import re | 10 import re |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 for line in handle: | 213 for line in handle: |
| 214 # Remove comments and whitespace | 214 # Remove comments and whitespace |
| 215 line = re.sub(r'#.*', '', line).strip() | 215 line = re.sub(r'#.*', '', line).strip() |
| 216 if not line: | 216 if not line: |
| 217 continue | 217 continue |
| 218 | 218 |
| 219 key, spec = parse_spec(deps_path, line) | 219 key, spec = parse_spec(deps_path, line) |
| 220 if spec: | 220 if spec: |
| 221 result[key] = spec | 221 result[key] = spec |
| 222 return result | 222 return result |
| 223 except IOError, e: | 223 except IOError as e: |
| 224 if e.errno != errno.ENOENT: | 224 if e.errno != errno.ENOENT: |
| 225 raise | 225 raise |
| 226 return None | 226 return None |
| 227 | 227 |
| 228 | 228 |
| 229 def safe_join(path, subpath): | 229 def safe_join(path, subpath): |
| 230 # This has been inspired by Flask's safe_join() function | 230 # This has been inspired by Flask's safe_join() function |
| 231 forbidden = {os.sep, os.altsep} - {posixpath.sep, None} | 231 forbidden = {os.sep, os.altsep} - {posixpath.sep, None} |
| 232 if any(sep in subpath for sep in forbidden): | 232 if any(sep in subpath for sep in forbidden): |
| 233 raise Exception('Illegal directory separator in dependency path %s' % su
bpath) | 233 raise Exception('Illegal directory separator in dependency path %s' % su
bpath) |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 ensure_repo(repodir, parenttype, target, vcs, _root.get(vcs, ''), source
) | 325 ensure_repo(repodir, parenttype, target, vcs, _root.get(vcs, ''), source
) |
| 326 update_repo(target, vcs, rev) | 326 update_repo(target, vcs, rev) |
| 327 resolve_deps(target, level + 1, self_update=False, | 327 resolve_deps(target, level + 1, self_update=False, |
| 328 overrideroots=overrideroots, skipdependencies=skipdependenc
ies) | 328 overrideroots=overrideroots, skipdependencies=skipdependenc
ies) |
| 329 | 329 |
| 330 if self_update and '_self' in config and '*' in config['_self']: | 330 if self_update and '_self' in config and '*' in config['_self']: |
| 331 source = safe_join(repodir, config['_self']['*']) | 331 source = safe_join(repodir, config['_self']['*']) |
| 332 try: | 332 try: |
| 333 with io.open(source, 'rb') as handle: | 333 with io.open(source, 'rb') as handle: |
| 334 sourcedata = handle.read() | 334 sourcedata = handle.read() |
| 335 except IOError, e: | 335 except IOError as e: |
| 336 if e.errno != errno.ENOENT: | 336 if e.errno != errno.ENOENT: |
| 337 raise | 337 raise |
| 338 logging.warning("File %s doesn't exist, skipping self-update" % sour
ce) | 338 logging.warning("File %s doesn't exist, skipping self-update" % sour
ce) |
| 339 return | 339 return |
| 340 | 340 |
| 341 target = __file__ | 341 target = __file__ |
| 342 with io.open(target, 'rb') as handle: | 342 with io.open(target, 'rb') as handle: |
| 343 targetdata = handle.read() | 343 targetdata = handle.read() |
| 344 | 344 |
| 345 if sourcedata != targetdata: | 345 if sourcedata != targetdata: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 372 args = parser.parse_args() | 372 args = parser.parse_args() |
| 373 | 373 |
| 374 if args.quiet: | 374 if args.quiet: |
| 375 logging.disable(logging.INFO) | 375 logging.disable(logging.INFO) |
| 376 | 376 |
| 377 repos = args.repos | 377 repos = args.repos |
| 378 if not len(repos): | 378 if not len(repos): |
| 379 repos = [os.path.dirname(__file__)] | 379 repos = [os.path.dirname(__file__)] |
| 380 for repo in repos: | 380 for repo in repos: |
| 381 resolve_deps(repo) | 381 resolve_deps(repo) |
| OLD | NEW |