diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-10 17:47:00 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-10 17:47:00 +0000 |
commit | 2ec654ac9138785f318b2b23e8a794829ad687d5 (patch) | |
tree | 65fd2dcd8a35464198ee586288c9cf23a67f90a2 | |
parent | c8a3935c613f29f8dc9da736fdb58633c13e7246 (diff) | |
download | chromium_src-2ec654ac9138785f318b2b23e8a794829ad687d5.zip chromium_src-2ec654ac9138785f318b2b23e8a794829ad687d5.tar.gz chromium_src-2ec654ac9138785f318b2b23e8a794829ad687d5.tar.bz2 |
Fix python scripts in src/ppapi/
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.
Minor python style fixes.
TBR=noelallen
BUG=105108
TEST=
Review URL: http://codereview.chromium.org/8653004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117045 0039d316-1c4b-4281-b951-d872f2087c98
20 files changed, 84 insertions, 113 deletions
diff --git a/ppapi/generate_ppapi_include_tests.py b/ppapi/generate_ppapi_include_tests.py index 01711ba..97daf24 100644..100755 --- a/ppapi/generate_ppapi_include_tests.py +++ b/ppapi/generate_ppapi_include_tests.py @@ -1,17 +1,18 @@ -#!/usr/bin/python - -# Copyright (c) 2010 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2012 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. -# This script should be run manually on occasion to make sure the gyp file and -# the includes tests are up to date. -# It does the following: -# - Verifies that all source code is in ppapi.gyp -# - Verifies that all sources in ppapi.gyp really do exist -# - Generates tests/test_c_includes.c -# - Generates tests/test_cpp_includes.cc -# These tests are checked in to SVN. +"""This script should be run manually on occasion to make sure the gyp file and +the includes tests are up to date. + +It does the following: + - Verifies that all source code is in ppapi.gyp + - Verifies that all sources in ppapi.gyp really do exist + - Generates tests/test_c_includes.c + - Generates tests/test_cpp_includes.cc +These tests are checked in to SVN. +""" # TODO(dmichael): Make this script execute as a gyp action, move the include # tests to some 'generated' area, and remove them from version # control. @@ -168,4 +169,3 @@ def main(): if __name__ == '__main__': sys.exit(main()) - diff --git a/ppapi/generate_ppapi_size_checks.py b/ppapi/generate_ppapi_size_checks.py index e1ba8a4..11b4d98 100644..100755 --- a/ppapi/generate_ppapi_size_checks.py +++ b/ppapi/generate_ppapi_size_checks.py @@ -1,12 +1,10 @@ -#!/usr/bin/python - -# Copyright (c) 2010 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2012 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. """This script should be run manually on occasion to make sure all PPAPI types have appropriate size checking. - """ import optparse @@ -20,9 +18,19 @@ import sys ARCH_DEPENDENT_STRING = "ArchDependentSize" +COPYRIGHT_STRING_C = ( +"""/* Copyright (c) %s 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. + * + * This file has compile assertions for the sizes of types that are dependent + * on the architecture for which they are compiled (i.e., 32-bit vs 64-bit). + */ + +""") % datetime.date.today().year -class SourceLocation: +class SourceLocation(object): """A class representing the source location of a definiton.""" def __init__(self, filename="", start_line=-1, end_line=-1): @@ -31,9 +39,7 @@ class SourceLocation: self.end_line = end_line - -class TypeInfo: - +class TypeInfo(object): """A class representing information about a C++ type. It contains the following fields: - kind: The Clang TypeClassName (Record, Enum, Typedef, Union, etc) @@ -80,8 +86,7 @@ class TypeInfo: self.arch_dependent = (arch_dependent_string == ARCH_DEPENDENT_STRING) -class FilePatch: - +class FilePatch(object): """A class representing a set of line-by-line changes to a particular file. None of the changes are applied until Apply is called. All line numbers are counted from 0. @@ -219,18 +224,6 @@ def IsMacroDefinedName(typename): return typename.find("PP_Dummy_Struct_For_") == 0 -COPYRIGHT_STRING_C = \ -"""/* Copyright (c) 2010 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. - * - * This file has compile assertions for the sizes of types that are dependent - * on the architecture for which they are compiled (i.e., 32-bit vs 64-bit). - */ - -""" - - def WriteArchSpecificCode(types, root, filename): """Write a header file that contains a compile-time assertion for the size of each of the given typeinfos, in to a file named filename rooted at root. @@ -429,4 +422,3 @@ def main(argv): if __name__ == '__main__': sys.exit(main(sys.argv[1:])) - diff --git a/ppapi/generators/generator.py b/ppapi/generators/generator.py index 3bb4ff5..2d3c703 100755 --- a/ppapi/generators/generator.py +++ b/ppapi/generators/generator.py @@ -1,6 +1,5 @@ -#!/usr/bin/python -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2012 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. @@ -15,16 +14,17 @@ from idl_c_header import HGen from idl_gen_pnacl import PnaclGen -def Main(args): +def Main(): + args = sys.argv[1:] + # If no arguments are provided, assume we are tring to rebuild the + # C headers with warnings off. + if not args: + args = ['--wnone', '--cgen', '--range=start,end'] + filenames = ParseOptions(args) ast = ParseFiles(filenames) return Generator.Run(ast) -if __name__ == '__main__': - args = sys.argv[1:] - - # If no arguments are provided, assume we are tring to rebuild the - # C headers with warnings off. - if not args: args = ['--wnone', '--cgen', '--range=start,end'] - sys.exit(Main(args)) +if __name__ == '__main__': + sys.exit(Main()) diff --git a/ppapi/generators/idl_ast.py b/ppapi/generators/idl_ast.py index 609253e..b7ad6f0 100644 --- a/ppapi/generators/idl_ast.py +++ b/ppapi/generators/idl_ast.py @@ -1,6 +1,4 @@ -#!/usr/bin/python -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Copyright (c) 2012 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. @@ -124,5 +122,3 @@ class IDLAst(IDLNode): node = self.namespace[name] for prop in properties: node.properties[prop] = properties[prop] - - diff --git a/ppapi/generators/idl_c_header.py b/ppapi/generators/idl_c_header.py index 536d73e..3cdf627 100644..100755 --- a/ppapi/generators/idl_c_header.py +++ b/ppapi/generators/idl_c_header.py @@ -1,5 +1,4 @@ -#!/usr/bin/python -# +#!/usr/bin/env python # Copyright (c) 2012 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. @@ -230,5 +229,4 @@ def Main(args): return failed if __name__ == '__main__': - retval = Main(sys.argv[1:]) - sys.exit(retval) + sys.exit(Main(sys.argv[1:])) diff --git a/ppapi/generators/idl_c_proto.py b/ppapi/generators/idl_c_proto.py index fa34b94..7ec0f94 100644..100755 --- a/ppapi/generators/idl_c_proto.py +++ b/ppapi/generators/idl_c_proto.py @@ -1,5 +1,4 @@ -#!/usr/bin/python -# +#!/usr/bin/env python # Copyright (c) 2012 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. diff --git a/ppapi/generators/idl_diff.py b/ppapi/generators/idl_diff.py index 9d1abbb..0d15fe8 100644..100755 --- a/ppapi/generators/idl_diff.py +++ b/ppapi/generators/idl_diff.py @@ -1,6 +1,5 @@ -#!/usr/bin/python -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2012 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. @@ -350,6 +349,6 @@ def Main(args): if input: print ' ** Matched expected diff. **' print '\n' + if __name__ == '__main__': sys.exit(Main(sys.argv[1:])) - diff --git a/ppapi/generators/idl_generator.py b/ppapi/generators/idl_generator.py index efc2325..81e8f6f 100644..100755 --- a/ppapi/generators/idl_generator.py +++ b/ppapi/generators/idl_generator.py @@ -1,6 +1,5 @@ -#!/usr/bin/python -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2012 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. diff --git a/ppapi/generators/idl_lexer.py b/ppapi/generators/idl_lexer.py index bf0b134..2700864 100644..100755 --- a/ppapi/generators/idl_lexer.py +++ b/ppapi/generators/idl_lexer.py @@ -1,6 +1,5 @@ -#!/usr/bin/python -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2012 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. @@ -308,8 +307,6 @@ def TestExpect(tokens): return -1 - - def Main(args): filenames = ParseOptions(args) @@ -328,5 +325,6 @@ def Main(args): sys.stderr.write('%s\n' % str(le)) return -1 + if __name__ == '__main__': sys.exit(Main(sys.argv[1:])) diff --git a/ppapi/generators/idl_lint.py b/ppapi/generators/idl_lint.py index 2c425c6..34fc62d 100644 --- a/ppapi/generators/idl_lint.py +++ b/ppapi/generators/idl_lint.py @@ -1,6 +1,4 @@ -#!/usr/bin/python -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Copyright (c) 2012 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. @@ -116,4 +114,3 @@ def Lint(ast): if warnings: WarnOut.Log('%s warning(s) for %s\n' % (warnings, name)) return skipList - diff --git a/ppapi/generators/idl_log.py b/ppapi/generators/idl_log.py index 1c30aa9..679c7d8 100644 --- a/ppapi/generators/idl_log.py +++ b/ppapi/generators/idl_log.py @@ -1,6 +1,4 @@ -#!/usr/bin/python -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Copyright (c) 2012 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. @@ -58,4 +56,3 @@ class IDLLog(object): ErrOut = IDLLog('Error', sys.stderr) WarnOut = IDLLog('Warning', sys.stdout) InfoOut = IDLLog('', sys.stdout) - diff --git a/ppapi/generators/idl_namespace.py b/ppapi/generators/idl_namespace.py index 29ac6c0..f7429c1 100644..100755 --- a/ppapi/generators/idl_namespace.py +++ b/ppapi/generators/idl_namespace.py @@ -1,6 +1,5 @@ -#!/usr/bin/python -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2012 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. @@ -245,6 +244,6 @@ def Main(args): print 'Passed.' return errors + if __name__ == '__main__': sys.exit(Main(sys.argv[1:])) - diff --git a/ppapi/generators/idl_node.py b/ppapi/generators/idl_node.py index 1372d38..e86955c 100644..100755 --- a/ppapi/generators/idl_node.py +++ b/ppapi/generators/idl_node.py @@ -1,6 +1,5 @@ -#!/usr/bin/python -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2012 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. @@ -358,6 +357,6 @@ def Main(): return -1 return 0 + if __name__ == '__main__': sys.exit(Main()) - diff --git a/ppapi/generators/idl_option.py b/ppapi/generators/idl_option.py index 5d75c28..714b686 100644 --- a/ppapi/generators/idl_option.py +++ b/ppapi/generators/idl_option.py @@ -1,6 +1,4 @@ -#!/usr/bin/python -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Copyright (c) 2012 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. @@ -107,4 +105,3 @@ def ParseOptions(args): sys.exit(-1) return filenames - diff --git a/ppapi/generators/idl_outfile.py b/ppapi/generators/idl_outfile.py index a747d7d..d717360 100644..100755 --- a/ppapi/generators/idl_outfile.py +++ b/ppapi/generators/idl_outfile.py @@ -1,5 +1,4 @@ -#!/usr/bin/python -# +#!/usr/bin/env python # Copyright (c) 2012 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. @@ -120,6 +119,7 @@ class IDLOutFile(object): return False + def TestFile(name, stringlist, force, update): errors = 0 @@ -155,8 +155,8 @@ def TestFile(name, stringlist, force, update): return 1 return 0 -if __name__ == '__main__': +def main(): errors = 0 stringlist = ['Test', 'Testing\n', 'Test'] filename = 'outtest.txt' @@ -173,4 +173,8 @@ if __name__ == '__main__': # Clean up file os.remove(filename) if not errors: InfoOut.Log('All tests pass.') - sys.exit(errors) + return errors + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/ppapi/generators/idl_parser.py b/ppapi/generators/idl_parser.py index 43fb967..a5e29ed 100644..100755 --- a/ppapi/generators/idl_parser.py +++ b/ppapi/generators/idl_parser.py @@ -1,6 +1,5 @@ -#!/usr/bin/python -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2012 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. @@ -976,6 +975,7 @@ def TestErrorFiles(filter): InfoOut.Log("Passed parsing test.") return total_errs + def TestNamespaceFiles(filter): idldir = os.path.split(sys.argv[0])[0] idldir = os.path.join(idldir, 'test_namespace', '*.idl') @@ -1049,5 +1049,6 @@ def Main(args): InfoOut.Log("%d files processed." % len(filenames)) return errs + if __name__ == '__main__': sys.exit(Main(sys.argv[1:])) diff --git a/ppapi/generators/idl_propertynode.py b/ppapi/generators/idl_propertynode.py index caf0974..24e10d9 100644..100755 --- a/ppapi/generators/idl_propertynode.py +++ b/ppapi/generators/idl_propertynode.py @@ -1,6 +1,5 @@ -#!/usr/bin/python -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2012 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. @@ -180,6 +179,7 @@ def MultiParentTest(): if not errors: InfoOut.Log('Passed MultiParentTest') return errors + def Main(): errors = 0 errors += PropertyTest() @@ -191,6 +191,6 @@ def Main(): return -1 return 0 + if __name__ == '__main__': sys.exit(Main()) - diff --git a/ppapi/generators/idl_release.py b/ppapi/generators/idl_release.py index a6670a2..ca350e1 100644..100755 --- a/ppapi/generators/idl_release.py +++ b/ppapi/generators/idl_release.py @@ -1,6 +1,5 @@ -#!/usr/bin/python -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2012 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. @@ -243,6 +242,7 @@ def TestReleaseNode(): assert not Foo23.InRange('M16', 'M17') print "TestReleaseNode - Passed" + def TestReleaseListWarning(): FooXX = IDLRelease(None, None) Foo1X = IDLRelease('M14', None) @@ -257,6 +257,7 @@ def TestReleaseListWarning(): assert warning print "TestReleaseListWarning - Passed" + def TestReleaseListError(): FooXX = IDLRelease(None, None) Foo1X = IDLRelease('M14', None) @@ -272,6 +273,7 @@ def TestReleaseListError(): assert error print "TestReleaseListError - Passed" + def TestReleaseListOK(): FooXX = IDLRelease(None, None) Foo1X = IDLRelease('M14', None) @@ -307,6 +309,7 @@ def TestReleaseListOK(): def TestReleaseMap(): print "TestReleaseMap- Passed" + def Main(args): TestReleaseNode() TestReleaseListWarning() @@ -315,6 +318,6 @@ def Main(args): print "Passed" return 0 + if __name__ == '__main__': sys.exit(Main(sys.argv[1:])) - diff --git a/ppapi/generators/idl_visitor.py b/ppapi/generators/idl_visitor.py index 3824141..1ea1c9c 100644 --- a/ppapi/generators/idl_visitor.py +++ b/ppapi/generators/idl_visitor.py @@ -1,6 +1,4 @@ -#!/usr/bin/python -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Copyright (c) 2012 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. @@ -81,5 +79,3 @@ class IDLRangeVisitor(object): if self.classList and node.cls not in self.classList: return False if not node.IsVersion(self.version): return False return True - - diff --git a/ppapi/native_client/src/tools/srpcgen.py b/ppapi/native_client/src/tools/srpcgen.py index c74e2cc..91901c1 100755 --- a/ppapi/native_client/src/tools/srpcgen.py +++ b/ppapi/native_client/src/tools/srpcgen.py @@ -1,4 +1,4 @@ -# -*- python -*- +#!/usr/bin/env python # Copyright (c) 2012 The Native Client Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -18,9 +18,6 @@ server or client stub file, as determined by the command line flag -s or -c. """ import getopt -#import re -#import string -#import StringIO import sys import os |