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

Side by Side Diff: third_party/closure_compiler/checker.py

Issue 476453002: Python readability review for dbeam@. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Runs Closure compiler on a JavaScript file to check for errors.""" 6 """Runs Closure compiler on a JavaScript file to check for errors."""
7 7
8 import argparse 8 import argparse
9 import os 9 import os
10 import re 10 import re
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 _found_java = False 58 _found_java = False
59 59
60 def __init__(self, verbose=False): 60 def __init__(self, verbose=False):
61 current_dir = os.path.join(os.path.dirname(__file__)) 61 current_dir = os.path.join(os.path.dirname(__file__))
62 self._compiler_jar = os.path.join(current_dir, "lib", "compiler.jar") 62 self._compiler_jar = os.path.join(current_dir, "lib", "compiler.jar")
63 self._runner_jar = os.path.join(current_dir, "runner", "runner.jar") 63 self._runner_jar = os.path.join(current_dir, "runner", "runner.jar")
64 self._temp_files = [] 64 self._temp_files = []
65 self._verbose = verbose 65 self._verbose = verbose
66 66
67 def _clean_up(self): 67 def _clean_up(self):
Dan Beam 2014/08/13 22:06:55 it seems like _protected_method() is preferred and
68 if not self._temp_files: 68 if not self._temp_files:
69 return 69 return
70 70
71 self._debug("Deleting temporary files: %s" % ", ".join(self._temp_files)) 71 self._debug("Deleting temporary files: %s" % ", ".join(self._temp_files))
72 for f in self._temp_files: 72 for f in self._temp_files:
73 os.remove(f) 73 os.remove(f)
74 self._temp_files = [] 74 self._temp_files = []
75 75
76 def _debug(self, msg, error=False): 76 def _debug(self, msg, error=False):
77 if self._verbose: 77 if self._verbose:
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 for source in opts.sources: 236 for source in opts.sources:
237 if not checker.check(source, depends=opts.depends, externs=opts.externs): 237 if not checker.check(source, depends=opts.depends, externs=opts.externs):
238 sys.exit(1) 238 sys.exit(1)
239 239
240 if opts.out_file: 240 if opts.out_file:
241 out_dir = os.path.dirname(opts.out_file) 241 out_dir = os.path.dirname(opts.out_file)
242 if not os.path.exists(out_dir): 242 if not os.path.exists(out_dir):
243 os.makedirs(out_dir) 243 os.makedirs(out_dir)
244 # TODO(dbeam): write compiled file to |opts.out_file|. 244 # TODO(dbeam): write compiled file to |opts.out_file|.
245 open(opts.out_file, "w").write("") 245 open(opts.out_file, "w").write("")
246
OLDNEW
« no previous file with comments | « no previous file | third_party/closure_compiler/processor.py » ('j') | third_party/closure_compiler/processor_test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698