diff options
author | scheib@chromium.org <scheib@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-13 21:48:33 +0000 |
---|---|---|
committer | scheib@chromium.org <scheib@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-13 21:48:33 +0000 |
commit | b37ba158f756b03f60d7406b5fb2dfd65f39fbff (patch) | |
tree | 1e6c831f78f9e61c27e2c5b49620a1cd6c46874f /tools | |
parent | 77b2986694925fa55313f8de323a34f38b25f5ba (diff) | |
download | chromium_src-b37ba158f756b03f60d7406b5fb2dfd65f39fbff.zip chromium_src-b37ba158f756b03f60d7406b5fb2dfd65f39fbff.tar.gz chromium_src-b37ba158f756b03f60d7406b5fb2dfd65f39fbff.tar.bz2 |
Revert of Add tools/boilerplate.py that will generate files with copyright headers and guards. (https://codereview.chromium.org/199003003/)
Reason for revert:
check_licenses failed:
/b/build/slave/Android_Builder__dbg_/build/src/android_webview/tools/webview_licenses.py scan
The following files contain a third-party license but are not in a listed third-party directory and are not whitelisted. You must add the following files to the whitelist.
tools/boilerplate.py
Original issue's description:
> Add tools/boilerplate.py that will generate files with copyright headers and guards.
>
> TEST=tools/boilerplate.py chrome/browser/ui/cocoa/test.{h,mm}
> R=thakis@chromium.org
>
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=256928
TBR=thakis@chromium.org,rsesek@chromium.org
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/199363005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256941 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/boilerplate.py | 91 |
1 files changed, 0 insertions, 91 deletions
diff --git a/tools/boilerplate.py b/tools/boilerplate.py deleted file mode 100755 index 74c63ee..0000000 --- a/tools/boilerplate.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env python -# Copyright 2014 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. - -"""Create files with copyright boilerplate and header include guards. - -Usage: tools/boilerplate.py path/to/file.{h,cc} -""" - -from datetime import date -import os -import os.path -import sys - -LINES = [ - 'Copyright %d The Chromium Authors. All rights reserved.' % - date.today().year, - 'Use of this source code is governed by a BSD-style license that can be', - 'found in the LICENSE file.' -] - -EXTENSIONS_TO_COMMENTS = { - 'h': '//', - 'cc': '//', - 'mm': '//', - 'js': '//', - 'py': '#' -} - -def _GetHeader(filename): - _, ext = os.path.splitext(filename) - ext = ext[1:] - comment = EXTENSIONS_TO_COMMENTS[ext] + ' ' - return '\n'.join([comment + line for line in LINES]) - - -def _CppHeader(filename): - guard = filename.replace('/', '_').replace('.', '_').upper() + '_' - return '\n'.join([ - '', - '#ifndef ' + guard, - '#define ' + guard, - '', - '#endif // ' + guard, - '' - ]) - - -def _CppImplementation(filename): - base, _ = os.path.splitext(filename) - include = '#include "' + base + '.h"' - return '\n'.join(['', include]) - - -def _CreateFile(filename): - contents = _GetHeader(filename) + '\n' - - if filename.endswith('.h'): - contents += _CppHeader(filename) - elif filename.endswith('.cc') or filename.endswith('.mm'): - contents += _CppImplementation(filename) - - fd = open(filename, 'w') - fd.write(contents) - fd.close() - - -def Main(): - files = sys.argv[1:] - if len(files) < 1: - print >> sys.stderr, 'Usage: boilerplate.py path/to/file.h path/to/file.cc' - return 1 - - # Perform checks first so that the entire operation is atomic. - for f in files: - _, ext = os.path.splitext(f) - if not ext[1:] in EXTENSIONS_TO_COMMENTS: - print >> sys.stderr, 'Unknown file type for %s' % f - return 2 - - if os.path.exists(f): - print >> sys.stderr, 'A file at path %s already exists' % f - return 2 - - for f in files: - _CreateFile(f) - - -if __name__ == '__main__': - sys.exit(Main()) |