Skip to content

Commit

Permalink
Made stab at fixing pylint warnings, supressing the rest.
Browse files Browse the repository at this point in the history
BUG=None
TEST=None
R=thakis@chromium.org,maruel@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10399131

git-svn-id: http://gyp.googlecode.com/svn/trunk@1392 78cadc50-ecff-11dd-a971-7dbc132099af
  • Loading branch information
bradnelson@google.com committed May 22, 2012
1 parent f635090 commit 46d34d8
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 46 deletions.
60 changes: 58 additions & 2 deletions PRESUBMIT.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2011 Google Inc. All rights reserved.
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

Expand All @@ -10,6 +10,60 @@
"""


PYLINT_BLACKLIST = [
# TODO: fix me.
# From SCons, not done in google style.
'test/lib/TestCmd.py',
'test/lib/TestCommon.py',
'test/lib/TestGyp.py',
# Needs style fix.
'pylib/gyp/generator/scons.py',
'pylib/gyp/generator/xcode.py',
]


PYLINT_DISABLED_WARNINGS = [
# TODO: fix me.
# Many tests include modules they don't use.
'W0611',
# Include order doesn't properly include local files?
'F0401',
# Some use of built-in names.
'W0622',
# Some unused variables.
'W0612',
# Operator not preceded/followed by space.
'C0323',
'C0322',
# Unnecessary semicolon.
'W0301',
# Unused argument.
'W0613',
# String has no effect (docstring in wrong place).
'W0105',
# Comma not followed by space.
'C0324',
# Access to a protected member.
'W0212',
# Bad indent.
'W0311',
# Line too long.
'C0301',
# Undefined variable.
'E0602',
# Not exception type specified.
'W0702',
# No member of that name.
'E1101',
# Dangerous default {}.
'W0102',
# Others, too many to sort.
'W0201', 'W0232', 'E1103', 'W0621', 'W0108', 'W0223', 'W0231',
'R0201', 'E0101', 'C0321', 'W0602', 'W0631', 'W0601', 'W0701',
'E0102', 'W0221', 'W0403',
]


def CheckChangeOnUpload(input_api, output_api):
report = []
report.extend(input_api.canned_checks.PanProjectChecks(
Expand Down Expand Up @@ -41,7 +95,9 @@ def CheckChangeOnCommit(input_api, output_api):
sys.path = ['pylib', 'test/lib'] + sys.path
report.extend(input_api.canned_checks.RunPylint(
input_api,
output_api))
output_api,
black_list=PYLINT_BLACKLIST,
disabled_warnings=PYLINT_DISABLED_WARNINGS))
finally:
sys.path = old_sys_path
return report
Expand Down
1 change: 0 additions & 1 deletion test/mac/gyptest-rebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import TestGyp

import os
import sys

if sys.platform == 'darwin':
Expand Down
3 changes: 1 addition & 2 deletions test/mac/gyptest-strip.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

# Copyright (c) 2011 Google Inc. All rights reserved.
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

Expand All @@ -10,7 +10,6 @@

import TestGyp

import os
import re
import subprocess
import sys
Expand Down
1 change: 0 additions & 1 deletion test/make/gyptest-dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
Verifies that .d files and all.deps are properly generated.
"""

import os
import TestGyp

# .d files are only used by the make build.
Expand Down
3 changes: 1 addition & 2 deletions test/msvs/props/gyptest-props.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"""

import TestGyp
import os

test = TestGyp.TestGyp(workdir='workarea_all', formats=['msvs'])

Expand All @@ -20,4 +19,4 @@

test.built_file_must_exist('Greet.exe')

test.pass_test()
test.pass_test()
3 changes: 1 addition & 2 deletions test/subdirectory/gyptest-subdir-all.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

# Copyright (c) 2009 Google Inc. All rights reserved.
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

Expand All @@ -11,7 +11,6 @@
"""

import TestGyp
import errno

# Ninja doesn't support running from subdirectories.
test = TestGyp.TestGyp(formats=['!ninja'])
Expand Down
4 changes: 1 addition & 3 deletions test/variables/commands/gyptest-commands-repeated.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

# Copyright (c) 2009 Google Inc. All rights reserved.
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

Expand All @@ -9,8 +9,6 @@
more then once..
"""

import os

import TestGyp

test = TestGyp.TestGyp(format='gypd')
Expand Down
6 changes: 4 additions & 2 deletions tools/pretty_gyp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
#!/usr/bin/env python

# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

Expand All @@ -16,7 +18,7 @@
# It takes into account quoted quotes, and makes sure that the quotes match.
# NOTE: It does not handle quotes that span more than one line, or
# cases where an escaped quote is preceeded by an escaped backslash.
quote_re_str = r'(?P<q>[\'"])(.*?)(?<![^\\][\\])(?P=q)'
QUOTE_RE_STR = r'(?P<q>[\'"])(.*?)(?<![^\\][\\])(?P=q)'
QUOTE_RE = re.compile(QUOTE_RE_STR)


Expand Down
4 changes: 2 additions & 2 deletions tools/pretty_sln.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

# Copyright (c) 2009 Google Inc. All rights reserved.
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

Expand Down Expand Up @@ -121,7 +121,7 @@ def PrintBuildOrder(projects, deps):
print "-- --"

built = []
for (project, dep_list) in sorted(deps.items()):
for (project, _) in sorted(deps.items()):
if project not in built:
BuildProject(project, built, projects, deps)

Expand Down
57 changes: 28 additions & 29 deletions tools/pretty_vcproj.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

# Copyright (c) 2009 Google Inc. All rights reserved.
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

Expand All @@ -27,37 +27,35 @@
class CmpTuple(object):
"""Compare function between 2 tuple."""
def __call__(self, x, y):
(key1, value1) = x
(key2, value2) = y
return cmp(key1, key2)
return cmp(x[0], y[0])


class CmpNode(object):
"""Compare function between 2 xml nodes."""

def get_string(self, node):
node_string = "node"
node_string += node.nodeName
if node.nodeValue:
node_string += node.nodeValue
def __call__(self, x, y):
def get_string(node):
node_string = "node"
node_string += node.nodeName
if node.nodeValue:
node_string += node.nodeValue

if node.attributes:
# We first sort by name, if present.
node_string += node.getAttribute("Name")
if node.attributes:
# We first sort by name, if present.
node_string += node.getAttribute("Name")

all_nodes = []
for (name, value) in node.attributes.items():
all_nodes.append((name, value))
all_nodes = []
for (name, value) in node.attributes.items():
all_nodes.append((name, value))

all_nodes.sort(CmpTuple())
for (name, value) in all_nodes:
node_string += name
node_string += value
all_nodes.sort(CmpTuple())
for (name, value) in all_nodes:
node_string += name
node_string += value

return node_string
return node_string

def __call__(self, x, y):
return cmp(self.get_string(x), self.get_string(y))
return cmp(get_string(x), get_string(y))


def PrettyPrintNode(node, indent=0):
Expand Down Expand Up @@ -152,17 +150,19 @@ def CleanupVcproj(node):
# Normalize the node, and remove all extranous whitespaces.
for sub_node in node.childNodes:
if sub_node.nodeType == Node.TEXT_NODE:
sub_node.data = sub_node.data.replace("\r", "")
sub_node.data = sub_node.data.replace("\n", "")
sub_node.data = sub_node.data.rstrip()
sub_node.data = sub_node.data.replace("\r", "")
sub_node.data = sub_node.data.replace("\n", "")
sub_node.data = sub_node.data.rstrip()

# Fix all the semicolon separated attributes to be sorted, and we also
# remove the dups.
if node.attributes:
for (name, value) in node.attributes.items():
sorted_list = sorted(value.split(';'))
unique_list = []
[unique_list.append(i) for i in sorted_list if not unique_list.count(i)]
for i in sorted_list:
if not unique_list.count(i):
unique_list.append(i)
node.setAttribute(name, ';'.join(unique_list))
if not value:
node.removeAttribute(name)
Expand Down Expand Up @@ -277,10 +277,9 @@ def MergeProperties(node1, node2):


def main(argv):
global REPLACEMENTS
"""Main function of this vcproj prettifier."""
global ARGUMENTS
ARGUMENTS = argv
"""Main function of this vcproj prettifier."""

# check if we have exactly 1 parameter.
if len(argv) < 2:
Expand Down Expand Up @@ -309,7 +308,7 @@ def main(argv):
# Extend the list of vsprops with all vsprops contained in the current
# vsprops.
for current_vsprops in vsprops_list:
vsprops_list.extend(GetChildrenVsprops(current_vsprops))
vsprops_list.extend(GetChildrenVsprops(current_vsprops))

# Now that we have all the vsprops, we need to merge them.
for current_vsprops in vsprops_list:
Expand Down

0 comments on commit 46d34d8

Please sign in to comment.