diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-23 22:22:20 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-23 22:22:20 +0000 |
commit | aa539ba4c9dc3e99a4e55f21a10fb79b9402637c (patch) | |
tree | 9cc8977263c4a73e65c7a52f96447bff83531265 /printing | |
parent | e51bdf3d4f7bb89497344af0b4a99ff10512c0d5 (diff) | |
download | chromium_src-aa539ba4c9dc3e99a4e55f21a10fb79b9402637c.zip chromium_src-aa539ba4c9dc3e99a4e55f21a10fb79b9402637c.tar.gz chromium_src-aa539ba4c9dc3e99a4e55f21a10fb79b9402637c.tar.bz2 |
Fix many* python scripts in src/
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.
* Do not fix them all at once otherwise the CL would be too large.
TBR=jamiewalch@chromium.org
BUG=105108
TEST=
Review URL: http://codereview.chromium.org/8665013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111427 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing')
-rwxr-xr-x | printing/cups_config_helper.py | 73 |
1 files changed, 41 insertions, 32 deletions
diff --git a/printing/cups_config_helper.py b/printing/cups_config_helper.py index 3c1dd41..3fe5fe0 100755 --- a/printing/cups_config_helper.py +++ b/printing/cups_config_helper.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/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. @@ -20,39 +20,48 @@ import subprocess import sys def usage(): - print 'usage: %s {--cflags|--ldflags|--libs}' % sys.argv[0] - sys.exit(1) + print 'usage: %s {--cflags|--ldflags|--libs}' % sys.argv[0] + def run_cups_config(mode): - """Run cups-config with all --cflags etc modes, parse out the mode we want, - and return those flags as a list.""" - - cups = subprocess.Popen(['cups-config', '--cflags', '--ldflags', '--libs'], - stdout=subprocess.PIPE) - flags = cups.communicate()[0].strip() - - flags_subset = [] - for flag in flags.split(): - flag_mode = None - if flag.startswith('-l'): - flag_mode = '--libs' - elif (flag.startswith('-L') or flag.startswith('-Wl,')): - flag_mode = '--ldflags' - elif (flag.startswith('-I') or flag.startswith('-D')): - flag_mode = '--cflags' - - # Be conservative: for flags where we don't know which mode they - # belong in, always include them. - if flag_mode is None or flag_mode == mode: - flags_subset.append(flag) - - return flags_subset - -if len(sys.argv) != 2: + """Run cups-config with all --cflags etc modes, parse out the mode we want, + and return those flags as a list.""" + + cups = subprocess.Popen(['cups-config', '--cflags', '--ldflags', '--libs'], + stdout=subprocess.PIPE) + flags = cups.communicate()[0].strip() + + flags_subset = [] + for flag in flags.split(): + flag_mode = None + if flag.startswith('-l'): + flag_mode = '--libs' + elif (flag.startswith('-L') or flag.startswith('-Wl,')): + flag_mode = '--ldflags' + elif (flag.startswith('-I') or flag.startswith('-D')): + flag_mode = '--cflags' + + # Be conservative: for flags where we don't know which mode they + # belong in, always include them. + if flag_mode is None or flag_mode == mode: + flags_subset.append(flag) + + return flags_subset + + +def main(): + if len(sys.argv) != 2: usage() + return 1 -mode = sys.argv[1] -if mode not in ('--cflags', '--libs', '--ldflags'): + mode = sys.argv[1] + if mode not in ('--cflags', '--libs', '--ldflags'): usage() -flags = run_cups_config(mode) -print ' '.join(flags) + return 1 + flags = run_cups_config(mode) + print ' '.join(flags) + return 0 + + +if __name__ == '__main__': + sys.exit(main()) |