diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-29 17:25:34 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-29 17:25:34 +0000 |
commit | cb155a802bdc49cfafea1c41e0f0a92168f1da09 (patch) | |
tree | bf0fae4855c7f4458d8e959455b9d12d6cd54d9d /tools/pragmaonce | |
parent | 9bec23957253b83955c4096903ad6293d1c6e1bb (diff) | |
download | chromium_src-cb155a802bdc49cfafea1c41e0f0a92168f1da09.zip chromium_src-cb155a802bdc49cfafea1c41e0f0a92168f1da09.tar.gz chromium_src-cb155a802bdc49cfafea1c41e0f0a92168f1da09.tar.bz2 |
Fix python scripts in src/tools/
Make sure that:
- shebang is only present for executable files
- shebang is #!/usr/bin/env python
- __main__ is only present for executable files
- file's executable bit is coherent
Also fix EOF LF to be only one.
TBR=timurrrr@chromium.org
BUG=105108
TEST=
Review URL: http://codereview.chromium.org/8678023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111960 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/pragmaonce')
-rwxr-xr-x[-rw-r--r--] | tools/pragmaonce/pragmaonce.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/tools/pragmaonce/pragmaonce.py b/tools/pragmaonce/pragmaonce.py index 15224c4..22f22a8 100644..100755 --- a/tools/pragmaonce/pragmaonce.py +++ b/tools/pragmaonce/pragmaonce.py @@ -1,13 +1,17 @@ -# Copyright (c) 2010 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +"""Tool to add "#pragma once" lines to files that don't have it yet. + +Usage: + find chrome -name '*.h' -exec tools/pragmaonce/pragmaonce.py {} \; +""" + import re import sys -# A tool to add "#pragma once" lines to files that don't have it yet. -# Intended usage: -# find chrome -name '*.h' -exec python tools/pragmaonce/pragmaonce.py {} \; # Some files have absurdly long comments at the top NUM_LINES_TO_SCAN_FOR_GUARD = 250 @@ -34,16 +38,17 @@ def main(filename): if index < len(lines) and re.match(r'#pragma once', lines[index]): # The pragma is already there. - return + return 0 lines.insert(index, "#pragma once\n") f = open(filename, 'w') f.write(''.join(lines)) f.close() + return 0 if __name__ == '__main__': if len(sys.argv) != 2: print >>sys.stderr, "Usage: %s inputfile" % sys.argv[0] sys.exit(1) - main(sys.argv[1]) + sys.exit(main(sys.argv[1])) |