Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: pylib/gyp/common.py

Issue 739303003: Cleanup pylint errors (Closed) Base URL: http://gyp.googlecode.com/svn/trunk
Patch Set: Fix mac Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pylib/gyp/__init__.py ('k') | pylib/gyp/generator/cmake.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 collections 7 import collections
8 import errno 8 import errno
9 import filecmp 9 import filecmp
10 import os.path 10 import os.path
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 def WriteOnDiff(filename): 322 def WriteOnDiff(filename):
323 """Write to a file only if the new contents differ. 323 """Write to a file only if the new contents differ.
324 324
325 Arguments: 325 Arguments:
326 filename: name of the file to potentially write to. 326 filename: name of the file to potentially write to.
327 Returns: 327 Returns:
328 A file like object which will write to temporary file and only overwrite 328 A file like object which will write to temporary file and only overwrite
329 the target if it differs (on close). 329 the target if it differs (on close).
330 """ 330 """
331 331
332 class Writer: 332 class Writer(object):
333 """Wrapper around file which only covers the target if it differs.""" 333 """Wrapper around file which only covers the target if it differs."""
334 def __init__(self): 334 def __init__(self):
335 # Pick temporary file. 335 # Pick temporary file.
336 tmp_fd, self.tmp_path = tempfile.mkstemp( 336 tmp_fd, self.tmp_path = tempfile.mkstemp(
337 suffix='.tmp', 337 suffix='.tmp',
338 prefix=os.path.split(filename)[1] + '.gyp.', 338 prefix=os.path.split(filename)[1] + '.gyp.',
339 dir=os.path.split(filename)[0]) 339 dir=os.path.split(filename)[0])
340 try: 340 try:
341 self.tmp_file = os.fdopen(tmp_fd, 'wb') 341 self.tmp_file = os.fdopen(tmp_fd, 'wb')
342 except Exception: 342 except Exception:
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 541
542 class CycleError(Exception): 542 class CycleError(Exception):
543 """An exception raised when an unexpected cycle is detected.""" 543 """An exception raised when an unexpected cycle is detected."""
544 def __init__(self, nodes): 544 def __init__(self, nodes):
545 self.nodes = nodes 545 self.nodes = nodes
546 def __str__(self): 546 def __str__(self):
547 return 'CycleError: cycle involving: ' + str(self.nodes) 547 return 'CycleError: cycle involving: ' + str(self.nodes)
548 548
549 549
550 def TopologicallySorted(graph, get_edges): 550 def TopologicallySorted(graph, get_edges):
551 """Topologically sort based on a user provided edge definition. 551 r"""Topologically sort based on a user provided edge definition.
552 552
553 Args: 553 Args:
554 graph: A list of node names. 554 graph: A list of node names.
555 get_edges: A function mapping from node name to a hashable collection 555 get_edges: A function mapping from node name to a hashable collection
556 of node names which this node has outgoing edges to. 556 of node names which this node has outgoing edges to.
557 Returns: 557 Returns:
558 A list containing all of the node in graph in topological order. 558 A list containing all of the node in graph in topological order.
559 It is assumed that calling get_edges once for each node and caching is 559 It is assumed that calling get_edges once for each node and caching is
560 cheaper than repeatedly calling get_edges. 560 cheaper than repeatedly calling get_edges.
561 Raises: 561 Raises:
(...skipping 17 matching lines...) Expand all
579 return 579 return
580 visited.add(node) 580 visited.add(node)
581 visiting.add(node) 581 visiting.add(node)
582 for neighbor in get_edges(node): 582 for neighbor in get_edges(node):
583 Visit(neighbor) 583 Visit(neighbor)
584 visiting.remove(node) 584 visiting.remove(node)
585 ordered_nodes.insert(0, node) 585 ordered_nodes.insert(0, node)
586 for node in sorted(graph): 586 for node in sorted(graph):
587 Visit(node) 587 Visit(node)
588 return ordered_nodes 588 return ordered_nodes
OLDNEW
« no previous file with comments | « pylib/gyp/__init__.py ('k') | pylib/gyp/generator/cmake.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698