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

Side by Side Diff: dart_format.py

Issue 933383002: Run dartfmt when invoking git cl format. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: more style Created 5 years, 10 months 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
« no previous file with comments | « no previous file | gclient_utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Redirects to the version of dartfmt checked into a gclient repo.
7
8 dartfmt binaries are pulled down during gclient sync in the mojo repo.
9
10 This tool is named dart_format.py instead of dartfmt to parallel
11 clang_format.py, which is in this same repository."""
12
13 import os
14 import subprocess
15 import sys
16
17 import gclient_utils
18
19 class NotFoundError(Exception):
20 """A file could not be found."""
21 def __init__(self, e):
22 Exception.__init__(self,
23 'Problem while looking for dartfmt in Chromium source tree:\n'
24 ' %s' % e)
25
26
27 def FindDartFmtToolInChromiumTree():
28 """Return a path to the dartfmt executable, or die trying."""
29 primary_solution_path = gclient_utils.GetPrimarySolutionPath()
30 if not primary_solution_path:
31 raise NotFoundError(
32 'Could not find checkout in any parent of the current path.')
33
34 dartfmt_path = os.path.join(primary_solution_path, 'third_party', 'dart-sdk',
35 'dart-sdk', 'bin', 'dartfmt')
36 if not os.path.exists(dartfmt_path):
37 raise NotFoundError('File does not exist: %s' % dartfmt_path)
38 return dartfmt_path
39
40
41 def main(args):
42 try:
43 tool = FindDartFmtToolInChromiumTree()
44 except NotFoundError, e:
45 print >> sys.stderr, e
46 sys.exit(1)
47
48 # Add some visibility to --help showing where the tool lives, since this
49 # redirection can be a little opaque.
50 help_syntax = ('-h', '--help', '-help', '-help-list', '--help-list')
51 if any(match in args for match in help_syntax):
52 print '\nDepot tools redirects you to the dartfmt at:\n %s\n' % tool
53
54 return subprocess.call([tool] + sys.argv[1:])
55
56
57 if __name__ == '__main__':
58 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | gclient_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698