Fix minor python code style issues

Fix some minor issues that were reported by pyflakes and pylint.

- Rename arguments to prevent redefinition of built-in 'dir'
- Rename method call to prevent redefinition of built-in 'help'
- Remove unused imports
- Prefix unused variable with underscore to prevent warning

Change-Id: Ia9e21c0f1a69af43f6e4566be46c31bdda540d2f
This commit is contained in:
David Pursehouse
2014-12-04 14:23:30 +09:00
parent 80babfe985
commit 686bfea7b3
4 changed files with 9 additions and 9 deletions

View File

@@ -25,7 +25,7 @@ def main():
patchset = None patchset = None
try: try:
opts, args = getopt.getopt(sys.argv[1:], '', \ opts, _args = getopt.getopt(sys.argv[1:], '', \
['change=', 'project=', 'branch=', 'commit=', 'patchset=']) ['change=', 'project=', 'branch=', 'commit=', 'patchset='])
except getopt.GetoptError as err: except getopt.GetoptError as err:
print('Error: %s' % (err)) print('Error: %s' % (err))

View File

@@ -18,7 +18,7 @@
import sys import sys
def help(): def print_help():
for (n, v) in vars(sys.modules['__main__']).items(): for (n, v) in vars(sys.modules['__main__']).items():
if not n.startswith("__") and not n in ['help', 'reload'] \ if not n.startswith("__") and not n in ['help', 'reload'] \
and str(type(v)) != "<type 'javapackage'>" \ and str(type(v)) != "<type 'javapackage'>" \
@@ -28,4 +28,4 @@ def help():
print "Welcome to the Gerrit Inspector" print "Welcome to the Gerrit Inspector"
print "Enter help() to see the above again, EOF to quit and stop Gerrit" print "Enter help() to see the above again, EOF to quit and stop Gerrit"
help() print_help()

View File

@@ -52,8 +52,8 @@ def _query_classpath(targets):
return deps return deps
def gen_project(name='gerrit', dir=ROOT): def gen_project(name='gerrit', root=ROOT):
p = path.join(dir, '.project') p = path.join(root, '.project')
with open(p, 'w') as fd: with open(p, 'w') as fd:
print("""\ print("""\
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
@@ -70,10 +70,10 @@ def gen_project(name='gerrit', dir=ROOT):
</projectDescription>\ </projectDescription>\
""", file=fd) """, file=fd)
def gen_plugin_classpath(dir): def gen_plugin_classpath(root):
p = path.join(dir, '.classpath') p = path.join(root, '.classpath')
with open(p, 'w') as fd: with open(p, 'w') as fd:
if path.exists(path.join(dir, 'src', 'test', 'java')): if path.exists(path.join(root, 'src', 'test', 'java')):
testpath = """ testpath = """
<classpathentry kind="src" path="src/test/java"\ <classpathentry kind="src" path="src/test/java"\
out="buck-out/eclipse/test"/>""" out="buck-out/eclipse/test"/>"""

View File

@@ -15,7 +15,7 @@
from __future__ import print_function from __future__ import print_function
from optparse import OptionParser from optparse import OptionParser
from os import getcwd, chdir, makedirs, path, symlink from os import chdir, makedirs, path, symlink
from subprocess import check_call, check_output from subprocess import check_call, check_output
import sys import sys