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

Unified Diff: tools/pragmaonce/pragmaonce.py

Issue 8678023: Fix python scripts in src/tools/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/playback_benchmark/run.py ('k') | tools/python/google/gethash_timer.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/pragmaonce/pragmaonce.py
diff --git a/tools/pragmaonce/pragmaonce.py b/tools/pragmaonce/pragmaonce.py
old mode 100644
new mode 100755
index 15224c49edbf149c6a7781e961b8beafb5885b64..22f22a8eff437f88a32bd9e1e0e27c59d55f68a5
--- 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]))
« no previous file with comments | « tools/playback_benchmark/run.py ('k') | tools/python/google/gethash_timer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698