OLD | NEW |
1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 Google Inc. 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 from __future__ import with_statement | 5 from __future__ import with_statement |
6 | 6 |
7 import errno | 7 import errno |
8 import filecmp | 8 import filecmp |
9 import os.path | 9 import os.path |
10 import re | 10 import re |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 os.remove(filename) | 384 os.remove(filename) |
385 os.rename(self.tmp_path, filename) | 385 os.rename(self.tmp_path, filename) |
386 except Exception: | 386 except Exception: |
387 # Don't leave turds behind. | 387 # Don't leave turds behind. |
388 os.unlink(self.tmp_path) | 388 os.unlink(self.tmp_path) |
389 raise | 389 raise |
390 | 390 |
391 return Writer() | 391 return Writer() |
392 | 392 |
393 | 393 |
| 394 def EnsureDirExists(path): |
| 395 """Make sure the directory for |path| exists.""" |
| 396 try: |
| 397 os.makedirs(os.path.dirname(path)) |
| 398 except OSError: |
| 399 pass |
| 400 |
| 401 |
394 def GetFlavor(params): | 402 def GetFlavor(params): |
395 """Returns |params.flavor| if it's set, the system's default flavor else.""" | 403 """Returns |params.flavor| if it's set, the system's default flavor else.""" |
396 flavors = { | 404 flavors = { |
397 'cygwin': 'win', | 405 'cygwin': 'win', |
398 'win32': 'win', | 406 'win32': 'win', |
399 'darwin': 'mac', | 407 'darwin': 'mac', |
400 } | 408 } |
401 | 409 |
402 if 'flavor' in params: | 410 if 'flavor' in params: |
403 return params['flavor'] | 411 return params['flavor'] |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 return | 512 return |
505 visited.add(node) | 513 visited.add(node) |
506 visiting.add(node) | 514 visiting.add(node) |
507 for neighbor in get_edges(node): | 515 for neighbor in get_edges(node): |
508 Visit(neighbor) | 516 Visit(neighbor) |
509 visiting.remove(node) | 517 visiting.remove(node) |
510 ordered_nodes.insert(0, node) | 518 ordered_nodes.insert(0, node) |
511 for node in sorted(graph): | 519 for node in sorted(graph): |
512 Visit(node) | 520 Visit(node) |
513 return ordered_nodes | 521 return ordered_nodes |
OLD | NEW |