Python cleanups, round 2: line too long, etc. - Line too long (>80) - Pointless continuation (\) characters - Trailing semi-colon - 'not foo in bar' -> 'foo not in bar' Change-Id: I7acb7f166d2f945005bf5578a740b887b1654597
diff --git a/Documentation/replace_macros.py b/Documentation/replace_macros.py index d9fa044..6f90697 100755 --- a/Documentation/replace_macros.py +++ b/Documentation/replace_macros.py
@@ -183,7 +183,8 @@ element.insertBefore(a, element.firstChild); // remove the link icon when the mouse is moved away, - // but keep it shown if the mouse is over the element, the link or the icon + // but keep it shown if the mouse is over the element, the link or + // the icon hide = function(evt) { if (document.elementFromPoint(evt.clientX, evt.clientY) != element && document.elementFromPoint(evt.clientX, evt.clientY) != a
diff --git a/contrib/check-valid-commit.py b/contrib/check-valid-commit.py index 60d3848..763ae3e 100755 --- a/contrib/check-valid-commit.py +++ b/contrib/check-valid-commit.py
@@ -10,7 +10,9 @@ SSH_USER = 'bot' SSH_HOST = 'localhost' SSH_PORT = 29418 -SSH_COMMAND = 'ssh %s@%s -p %d gerrit approve ' % (SSH_USER, SSH_HOST, SSH_PORT) +SSH_COMMAND = 'ssh %s@%s -p %d gerrit approve ' % (SSH_USER, + SSH_HOST, + SSH_PORT) FAILURE_SCORE = '--code-review=-2' FAILURE_MESSAGE = 'This commit message does not match the standard.' \ + ' Please correct the commit message and upload a replacement patch.' @@ -26,8 +28,9 @@ patchset = None try: - opts, _args = getopt.getopt(sys.argv[1:], '', \ - ['change=', 'project=', 'branch=', 'commit=', 'patchset=']) + opts, _args = getopt.getopt(sys.argv[1:], '', + ['change=', 'project=', 'branch=', + 'commit=', 'patchset=']) except getopt.GetoptError as err: print('Error: %s' % (err)) usage() @@ -49,8 +52,7 @@ usage() sys.exit(-1) - if change == None or project == None or branch == None \ - or commit == None or patchset == None: + if any(p is None for p in [change, project, branch, commit, patchset]): usage() sys.exit(-1) @@ -58,7 +60,7 @@ status, output = subprocess.getstatusoutput(command) if status != 0: - print('Error running \'%s\'. status: %s, output:\n\n%s' % \ + print('Error running \'%s\'. status: %s, output:\n\n%s' % (command, status, output)) sys.exit(-1) @@ -66,7 +68,7 @@ commitLines = commitMessage.split('\n') if len(commitLines) > 1 and len(commitLines[1]) != 0: - fail(commit, 'Invalid commit summary. The summary must be ' \ + fail(commit, 'Invalid commit summary. The summary must be ' + 'one line followed by a blank line.') i = 0 @@ -80,7 +82,7 @@ def usage(): print('Usage:\n') - print(sys.argv[0] + ' --change <change id> --project <project name> ' \ + print(sys.argv[0] + ' --change <change id> --project <project name> ' + '--branch <branch> --commit <sha1> --patchset <patchset id>')
diff --git a/contrib/populate-fixture-data.py b/contrib/populate-fixture-data.py index 94e2c35..07a0f01 100755 --- a/contrib/populate-fixture-data.py +++ b/contrib/populate-fixture-data.py
@@ -47,82 +47,86 @@ # Random names from US Census Data FIRST_NAMES = [ - "Casey", "Yesenia", "Shirley", "Tara", "Wanda", "Sheryl", "Jaime", "Elaine", - "Charlotte", "Carly", "Bonnie", "Kirsten", "Kathryn", "Carla", "Katrina", - "Melody", "Suzanne", "Sandy", "Joann", "Kristie", "Sally", "Emma", "Susan", - "Amanda", "Alyssa", "Patty", "Angie", "Dominique", "Cynthia", "Jennifer", - "Theresa", "Desiree", "Kaylee", "Maureen", "Jeanne", "Kellie", "Valerie", - "Nina", "Judy", "Diamond", "Anita", "Rebekah", "Stefanie", "Kendra", "Erin", - "Tammie", "Tracey", "Bridget", "Krystal", "Jasmin", "Sonia", "Meghan", - "Rebecca", "Jeanette", "Meredith", "Beverly", "Natasha", "Chloe", "Selena", - "Teresa", "Sheena", "Cassandra", "Rhonda", "Tami", "Jodi", "Shelly", "Angela", - "Kimberly", "Terry", "Joanna", "Isabella", "Lindsey", "Loretta", "Dana", - "Veronica", "Carolyn", "Laura", "Karen", "Dawn", "Alejandra", "Cassie", - "Lorraine", "Yolanda", "Kerry", "Stephanie", "Caitlin", "Melanie", "Kerri", - "Doris", "Sandra", "Beth", "Carol", "Vicki", "Shelia", "Bethany", "Rachael", - "Donna", "Alexandra", "Barbara", "Ana", "Jillian", "Ann", "Rachel", "Lauren", - "Hayley", "Misty", "Brianna", "Tanya", "Danielle", "Courtney", "Jacqueline", - "Becky", "Christy", "Alisha", "Phyllis", "Faith", "Jocelyn", "Nancy", - "Gloria", "Kristen", "Evelyn", "Julie", "Julia", "Kara", "Chelsey", "Cassidy", - "Jean", "Chelsea", "Jenny", "Diana", "Haley", "Kristine", "Kristina", "Erika", - "Jenna", "Alison", "Deanna", "Abigail", "Melissa", "Sierra", "Linda", - "Monica", "Tasha", "Traci", "Yvonne", "Tracy", "Marie", "Maria", "Michaela", - "Stacie", "April", "Morgan", "Cathy", "Darlene", "Cristina", "Emily" - "Ian", "Russell", "Phillip", "Jay", "Barry", "Brad", "Frederick", "Fernando", - "Timothy", "Ricardo", "Bernard", "Daniel", "Ruben", "Alexis", "Kyle", "Malik", - "Norman", "Kent", "Melvin", "Stephen", "Daryl", "Kurt", "Greg", "Alex", - "Mario", "Riley", "Marvin", "Dan", "Steven", "Roberto", "Lucas", "Leroy", - "Preston", "Drew", "Fred", "Casey", "Wesley", "Elijah", "Reginald", "Joel", - "Christopher", "Jacob", "Luis", "Philip", "Mark", "Rickey", "Todd", "Scott", - "Terrence", "Jim", "Stanley", "Bobby", "Thomas", "Gabriel", "Tracy", "Marcus", - "Peter", "Michael", "Calvin", "Herbert", "Darryl", "Billy", "Ross", "Dustin", + "Casey", "Yesenia", "Shirley", "Tara", "Wanda", "Sheryl", "Jaime", + "Elaine", "Charlotte", "Carly", "Bonnie", "Kirsten", "Kathryn", "Carla", + "Katrina", "Melody", "Suzanne", "Sandy", "Joann", "Kristie", "Sally", + "Emma", "Susan", "Amanda", "Alyssa", "Patty", "Angie", "Dominique", + "Cynthia", "Jennifer", "Theresa", "Desiree", "Kaylee", "Maureen", + "Jeanne", "Kellie", "Valerie", "Nina", "Judy", "Diamond", "Anita", + "Rebekah", "Stefanie", "Kendra", "Erin", "Tammie", "Tracey", "Bridget", + "Krystal", "Jasmin", "Sonia", "Meghan", "Rebecca", "Jeanette", "Meredith", + "Beverly", "Natasha", "Chloe", "Selena", "Teresa", "Sheena", "Cassandra", + "Rhonda", "Tami", "Jodi", "Shelly", "Angela", "Kimberly", "Terry", + "Joanna", "Isabella", "Lindsey", "Loretta", "Dana", "Veronica", "Carolyn", + "Laura", "Karen", "Dawn", "Alejandra", "Cassie", "Lorraine", "Yolanda", + "Kerry", "Stephanie", "Caitlin", "Melanie", "Kerri", "Doris", "Sandra", + "Beth", "Carol", "Vicki", "Shelia", "Bethany", "Rachael", "Donna", + "Alexandra", "Barbara", "Ana", "Jillian", "Ann", "Rachel", "Lauren", + "Hayley", "Misty", "Brianna", "Tanya", "Danielle", "Courtney", + "Jacqueline", "Becky", "Christy", "Alisha", "Phyllis", "Faith", "Jocelyn", + "Nancy", "Gloria", "Kristen", "Evelyn", "Julie", "Julia", "Kara", + "Chelsey", "Cassidy", "Jean", "Chelsea", "Jenny", "Diana", "Haley", + "Kristine", "Kristina", "Erika", "Jenna", "Alison", "Deanna", "Abigail", + "Melissa", "Sierra", "Linda", "Monica", "Tasha", "Traci", "Yvonne", + "Tracy", "Marie", "Maria", "Michaela", "Stacie", "April", "Morgan", + "Cathy", "Darlene", "Cristina", "Emily" "Ian", "Russell", "Phillip", "Jay", + "Barry", "Brad", "Frederick", "Fernando", "Timothy", "Ricardo", "Bernard", + "Daniel", "Ruben", "Alexis", "Kyle", "Malik", "Norman", "Kent", "Melvin", + "Stephen", "Daryl", "Kurt", "Greg", "Alex", "Mario", "Riley", "Marvin", + "Dan", "Steven", "Roberto", "Lucas", "Leroy", "Preston", "Drew", "Fred", + "Casey", "Wesley", "Elijah", "Reginald", "Joel", "Christopher", "Jacob", + "Luis", "Philip", "Mark", "Rickey", "Todd", "Scott", "Terrence", "Jim", + "Stanley", "Bobby", "Thomas", "Gabriel", "Tracy", "Marcus", "Peter", + "Michael", "Calvin", "Herbert", "Darryl", "Billy", "Ross", "Dustin", "Jaime", "Adam", "Henry", "Xavier", "Dominic", "Lonnie", "Danny", "Victor", "Glen", "Perry", "Jackson", "Grant", "Gerald", "Garrett", "Alejandro", "Eddie", "Alan", "Ronnie", "Mathew", "Dave", "Wayne", "Joe", "Craig", "Terry", "Chris", "Randall", "Parker", "Francis", "Keith", "Neil", "Caleb", "Jon", "Earl", "Taylor", "Bryce", "Brady", "Max", "Sergio", "Leon", "Gene", - "Darin", "Bill", "Edgar", "Antonio", "Dalton", "Arthur", "Austin", "Cristian", - "Kevin", "Omar", "Kelly", "Aaron", "Ethan", "Tom", "Isaac", "Maurice", - "Gilbert", "Hunter", "Willie", "Harry", "Dale", "Darius", "Jerome", "Jason", - "Harold", "Kerry", "Clarence", "Gregg", "Shane", "Eduardo", "Micheal", - "Howard", "Vernon", "Rodney", "Anthony", "Levi", "Larry", "Franklin", "Jimmy", - "Jonathon", "Carl", + "Darin", "Bill", "Edgar", "Antonio", "Dalton", "Arthur", "Austin", + "Cristian", "Kevin", "Omar", "Kelly", "Aaron", "Ethan", "Tom", "Isaac", + "Maurice", "Gilbert", "Hunter", "Willie", "Harry", "Dale", "Darius", + "Jerome", "Jason", "Harold", "Kerry", "Clarence", "Gregg", "Shane", + "Eduardo", "Micheal", "Howard", "Vernon", "Rodney", "Anthony", "Levi", + "Larry", "Franklin", "Jimmy", "Jonathon", "Carl", ] LAST_NAMES = [ - "Savage", "Hendrix", "Moon", "Larsen", "Rocha", "Burgess", "Bailey", "Farley", - "Moses", "Schmidt", "Brown", "Hoover", "Klein", "Jennings", "Braun", "Rangel", - "Casey", "Dougherty", "Hancock", "Wolf", "Henry", "Thomas", "Bentley", - "Barnett", "Kline", "Pitts", "Rojas", "Sosa", "Paul", "Hess", "Chase", - "Mckay", "Bender", "Colins", "Montoya", "Townsend", "Potts", "Ayala", "Avery", - "Sherman", "Tapia", "Hamilton", "Ferguson", "Huang", "Hooper", "Zamora", - "Logan", "Lloyd", "Quinn", "Monroe", "Brock", "Ibarra", "Fowler", "Weiss", - "Montgomery", "Diaz", "Dixon", "Olson", "Robertson", "Arias", "Benjamin", - "Abbott", "Stein", "Schroeder", "Beck", "Velasquez", "Barber", "Nichols", - "Ortiz", "Burns", "Moody", "Stokes", "Wilcox", "Rush", "Michael", "Kidd", - "Rowland", "Mclean", "Saunders", "Chung", "Newton", "Potter", "Hickman", - "Ray", "Larson", "Figueroa", "Duncan", "Sparks", "Rose", "Hodge", "Huynh", - "Joseph", "Morales", "Beasley", "Mora", "Fry", "Ross", "Novak", "Hahn", - "Wise", "Knight", "Frederick", "Heath", "Pollard", "Vega", "Mcclain", - "Buckley", "Conrad", "Cantrell", "Bond", "Mejia", "Wang", "Lewis", "Johns", - "Mcknight", "Callahan", "Reynolds", "Norris", "Burnett", "Carey", "Jacobson", - "Oneill", "Oconnor", "Leonard", "Mckenzie", "Hale", "Delgado", "Spence", - "Brandt", "Obrien", "Bowman", "James", "Avila", "Roberts", "Barker", "Cohen", + "Savage", "Hendrix", "Moon", "Larsen", "Rocha", "Burgess", "Bailey", + "Farley", "Moses", "Schmidt", "Brown", "Hoover", "Klein", "Jennings", + "Braun", "Rangel", "Casey", "Dougherty", "Hancock", "Wolf", "Henry", + "Thomas", "Bentley", "Barnett", "Kline", "Pitts", "Rojas", "Sosa", "Paul", + "Hess", "Chase", "Mckay", "Bender", "Colins", "Montoya", "Townsend", + "Potts", "Ayala", "Avery", "Sherman", "Tapia", "Hamilton", "Ferguson", + "Huang", "Hooper", "Zamora", "Logan", "Lloyd", "Quinn", "Monroe", "Brock", + "Ibarra", "Fowler", "Weiss", "Montgomery", "Diaz", "Dixon", "Olson", + "Robertson", "Arias", "Benjamin", "Abbott", "Stein", "Schroeder", "Beck", + "Velasquez", "Barber", "Nichols", "Ortiz", "Burns", "Moody", "Stokes", + "Wilcox", "Rush", "Michael", "Kidd", "Rowland", "Mclean", "Saunders", + "Chung", "Newton", "Potter", "Hickman", "Ray", "Larson", "Figueroa", + "Duncan", "Sparks", "Rose", "Hodge", "Huynh", "Joseph", "Morales", + "Beasley", "Mora", "Fry", "Ross", "Novak", "Hahn", "Wise", "Knight", + "Frederick", "Heath", "Pollard", "Vega", "Mcclain", "Buckley", "Conrad", + "Cantrell", "Bond", "Mejia", "Wang", "Lewis", "Johns", "Mcknight", + "Callahan", "Reynolds", "Norris", "Burnett", "Carey", "Jacobson", "Oneill", + "Oconnor", "Leonard", "Mckenzie", "Hale", "Delgado", "Spence", "Brandt", + "Obrien", "Bowman", "James", "Avila", "Roberts", "Barker", "Cohen", "Bradley", "Prince", "Warren", "Summers", "Little", "Caldwell", "Garrett", "Hughes", "Norton", "Burke", "Holden", "Merritt", "Lee", "Frank", "Wiley", "Ho", "Weber", "Keith", "Winters", "Gray", "Watts", "Brady", "Aguilar", "Nicholson", "David", "Pace", "Cervantes", "Davis", "Baxter", "Sanchez", - "Singleton", "Taylor", "Strickland", "Glenn", "Valentine", "Roy", "Cameron", - "Beard", "Norman", "Fritz", "Anthony", "Koch", "Parrish", "Herman", "Hines", - "Sutton", "Gallegos", "Stephenson", "Lozano", "Franklin", "Howe", "Bauer", - "Love", "Ali", "Ellison", "Lester", "Guzman", "Jarvis", "Espinoza", - "Fletcher", "Burton", "Woodard", "Peterson", "Barajas", "Richard", "Bryan", - "Goodman", "Cline", "Rowe", "Faulkner", "Crawford", "Mueller", "Patterson", - "Hull", "Walton", "Wu", "Flores", "York", "Dickson", "Barnes", "Fisher", - "Strong", "Juarez", "Fitzgerald", "Schmitt", "Blevins", "Villa", "Sullivan", - "Velazquez", "Horton", "Meadows", "Riley", "Barrera", "Neal", "Mendez", - "Mcdonald", "Floyd", "Lynch", "Mcdowell", "Benson", "Hebert", "Livingston", - "Davies", "Richardson", "Vincent", "Davenport", "Osborn", "Mckee", "Marshall", + "Singleton", "Taylor", "Strickland", "Glenn", "Valentine", "Roy", + "Cameron", "Beard", "Norman", "Fritz", "Anthony", "Koch", "Parrish", + "Herman", "Hines", "Sutton", "Gallegos", "Stephenson", "Lozano", + "Franklin", "Howe", "Bauer", "Love", "Ali", "Ellison", "Lester", "Guzman", + "Jarvis", "Espinoza", "Fletcher", "Burton", "Woodard", "Peterson", + "Barajas", "Richard", "Bryan", "Goodman", "Cline", "Rowe", "Faulkner", + "Crawford", "Mueller", "Patterson", "Hull", "Walton", "Wu", "Flores", + "York", "Dickson", "Barnes", "Fisher", "Strong", "Juarez", "Fitzgerald", + "Schmitt", "Blevins", "Villa", "Sullivan", "Velazquez", "Horton", + "Meadows", "Riley", "Barrera", "Neal", "Mendez", "Mcdonald", "Floyd", + "Lynch", "Mcdowell", "Benson", "Hebert", "Livingston", "Davies", + "Richardson", "Vincent", "Davenport", "Osborn", "Mckee", "Marshall", "Ferrell", "Martinez", "Melton", "Mercer", "Yoder", "Jacobs", "Mcdaniel", "Mcmillan", "Peters", "Atkinson", "Wood", "Briggs", "Valencia", "Chandler", "Rios", "Hunter", "Bean", "Hicks", "Hays", "Lucero", "Malone", "Waller", @@ -149,9 +153,10 @@ def fetch_admin_group(): global GROUP_ADMIN # Get admin group - r = json.loads(clean(requests.get(BASE_URL + "groups/" + "?suggest=ad&p=All-Projects", - headers=HEADERS, - auth=ADMIN_BASIC_AUTH).text)) + r = json.loads(clean(requests.get( + BASE_URL + "groups/?suggest=ad&p=All-Projects", + headers=HEADERS, + auth=ADMIN_BASIC_AUTH).text)) admin_group_name = r.keys()[0] GROUP_ADMIN = r[admin_group_name] GROUP_ADMIN["name"] = admin_group_name @@ -160,7 +165,8 @@ def generate_random_text(): return " ".join([random.choice("lorem ipsum " "doleret delendam " - "\n esse".split(" ")) for _ in range(1, 100)]) + "\n esse".split(" ")) for _ in range(1, + 100)]) def set_up():
diff --git a/polygerrit-ui/app/template_test_srcs/convert_for_template_tests.py b/polygerrit-ui/app/template_test_srcs/convert_for_template_tests.py index af0d051..579e783 100644 --- a/polygerrit-ui/app/template_test_srcs/convert_for_template_tests.py +++ b/polygerrit-ui/app/template_test_srcs/convert_for_template_tests.py
@@ -1,5 +1,6 @@ -import os, re, json -from shutil import copyfile, rmtree +import json +import os +import re polymerRegex = r"Polymer\({" polymerCompiledRegex = re.compile(polymerRegex) @@ -22,8 +23,9 @@ with _open(fileIn) as f: file_str = f.read() match = behaviorCompiledRegex.search(file_str) - if (match): - with _open("polygerrit-ui/temp/behaviors/" + fileOut.replace("html", "js"), "w+") as f: + if match: + with _open("polygerrit-ui/temp/behaviors/" + + fileOut.replace("html", "js"), "w+") as f: f.write(match.group(1)) @@ -35,7 +37,8 @@ def generateStubBehavior(behaviorName): - with _open("polygerrit-ui/temp/behaviors/" + behaviorName + ".js", "w+") as f: + with _open("polygerrit-ui/temp/behaviors/" + + behaviorName + ".js", "w+") as f: f.write("/** @polymerBehavior **/\n" + behaviorName + "= {};") @@ -50,12 +53,16 @@ package = root.replace("/", ".") + "." + fileOut with _open("polygerrit-ui/temp/" + fileOut, "w+") as f: - mainFileContents = re.sub(polymerCompiledRegex, "exports = Polymer({", file_str_no_fn.group(1)).replace("'use strict';", "") - f.write("/** \n" \ - "* @fileoverview \n" \ - "* @suppress {missingProperties} \n" \ - "*/ \n\n" \ - "goog.module('polygerrit." + package + "')\n\n" + mainFileContents) + mainFileContents = re.sub( + polymerCompiledRegex, + "exports = Polymer({", + file_str_no_fn.group(1)).replace("'use strict';", "") + f.write("/** \n" + "* @fileoverview \n" + "* @suppress {missingProperties} \n" + "*/ \n\n" + "goog.module('polygerrit." + package + "')\n\n" + + mainFileContents) # Add package and javascript to files object. elements[key]["js"] = "polygerrit-ui/temp/" + fileOut @@ -63,17 +70,20 @@ def writeTempFile(file, root): - # This is included in an extern because it is directly on the window object. + # This is included in an extern because it is directly on the window object # (for now at least). if "gr-reporting" in file: return key = file.split('.')[0] - if not key in elements: + if key not in elements: # gr-app doesn't have an additional level - elements[key] = {"directory": 'gr-app' if len(root.split("/")) < 4 else root.split("/")[3]} + elements[key] = { + "directory": + 'gr-app' if len(root.split("/")) < 4 else root.split("/")[3] + } if file.endswith(".html") and not file.endswith("_test.html"): - # gr-navigation is treated like a behavior rather than a standard element - # because of the way it added to the Gerrit object. + # gr-navigation is treated like a behavior rather than a standard + # element because of the way it added to the Gerrit object. if file.endswith("gr-navigation.html"): replaceBehaviorLikeHTML(os.path.join(root, file), file) else: @@ -105,7 +115,8 @@ generateStubBehavior("Polymer.IronOverlayBehavior") generateStubBehavior("Polymer.IronFitBehavior") - #TODO figure out something to do with iron-overlay-behavior. it is hard-coded reformatted. + # TODO figure out something to do with iron-overlay-behavior. + # it is hard-coded reformatted. with _open("polygerrit-ui/temp/map.json", "w+") as f: f.write(json.dumps(elements))
diff --git a/resources/com/google/gerrit/pgm/Startup.py b/resources/com/google/gerrit/pgm/Startup.py index adc6706..ec18f42 100644 --- a/resources/com/google/gerrit/pgm/Startup.py +++ b/resources/com/google/gerrit/pgm/Startup.py
@@ -22,7 +22,7 @@ def print_help(): for (n, v) in vars(sys.modules['__main__']).items(): - if not n.startswith("__") and not n in ['help', 'reload'] \ + if not n.startswith("__") and n not in ['help', 'reload'] \ and str(type(v)) != "<type 'javapackage'>" \ and not str(v).startswith("<module"): print("\"%s\" is \"%s\"" % (n, v))
diff --git a/tools/bzl/license-map.py b/tools/bzl/license-map.py index bf12883..476ccb9 100644 --- a/tools/bzl/license-map.py +++ b/tools/bzl/license-map.py
@@ -51,9 +51,8 @@ exit(1) if args.asciidoctor: - print( -# We don't want any blank line before "= Gerrit Code Review - Licenses" -"""= Gerrit Code Review - Licenses + # We don't want any blank line before "= Gerrit Code Review - Licenses" + print("""= Gerrit Code Review - Licenses Gerrit open source software is licensed under the <<Apache2_0,Apache License 2.0>>. Executable distributions also include other software @@ -125,8 +124,7 @@ print() if args.asciidoctor: - print( -""" + print(""" GERRIT ------ Part of link:index.html[Gerrit Code Review]
diff --git a/tools/download_file.py b/tools/download_file.py index 58c103b..29398e6 100755 --- a/tools/download_file.py +++ b/tools/download_file.py
@@ -106,7 +106,8 @@ try: check_call(['curl', '--proxy-anyauth', '-ksSfLo', cache_ent, src_url]) except OSError as err: - print('could not invoke curl: %s\nis curl installed?' % err, file=stderr) + print('could not invoke curl: %s\nis curl installed?' % err, + file=stderr) exit(1) except CalledProcessError as err: print('error using curl: %s' % err, file=stderr)
diff --git a/tools/eclipse/project.py b/tools/eclipse/project.py index f733b8b..b99c04e 100755 --- a/tools/eclipse/project.py +++ b/tools/eclipse/project.py
@@ -184,7 +184,8 @@ else: # Don't mess up with Bazel internal test runner dependencies. # When we use Eclipse we rely on it for running the tests - if p.endswith("external/bazel_tools/tools/jdk/TestRunner_deploy.jar"): + if p.endswith( + "external/bazel_tools/tools/jdk/TestRunner_deploy.jar"): continue if p.startswith("external"): p = path.join(ext, p) @@ -239,9 +240,10 @@ if args.plugins: classpathentry('lib', j, s, exported=True) else: - # Filter out the source JARs that we pull through transitive closure of - # GWT plugin API (we add source directories themself). Exception is - # libEdit-src.jar, that is needed for GWT SDM to work. + # Filter out the source JARs that we pull through transitive + # closure of GWT plugin API (we add source directories + # themselves). Exception is libEdit-src.jar, that is needed + # for GWT SDM to work. m = java_library.match(j) if m: if m.group(1).startswith("gerrit-") and \ @@ -279,7 +281,8 @@ def gen_factorypath(ext): - doc = minidom.getDOMImplementation().createDocument(None, 'factorypath', None) + doc = minidom.getDOMImplementation().createDocument(None, 'factorypath', + None) for jar in _query_classpath(AUTO): e = doc.createElement('factorypathentry') e.setAttribute('kind', 'EXTJAR') @@ -306,7 +309,8 @@ makedirs(path.join(ROOT, gwt_working_dir)) try: - check_call(_build_bazel_cmd('build', MAIN, GWT, '//java/org/eclipse/jgit:libEdit-src.jar')) + check_call(_build_bazel_cmd('build', MAIN, GWT, + '//java/org/eclipse/jgit:libEdit-src.jar')) except CalledProcessError: exit(1) except KeyboardInterrupt:
diff --git a/tools/js/bower2bazel.py b/tools/js/bower2bazel.py index 49432b4..7b24524 100755 --- a/tools/js/bower2bazel.py +++ b/tools/js/bower2bazel.py
@@ -13,9 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Suggested call sequence: +""" +Suggested call sequence: -python tools/js/bower2bazel.py -w lib/js/bower_archives.bzl -b lib/js/bower_components.bzl +python tools/js/bower2bazel.py -w lib/js/bower_archives.bzl \ + -b lib/js/bower_components.bzl """ from __future__ import print_function @@ -31,7 +33,7 @@ import glob import bowerutil -# list of licenses for packages that don't specify one in their bower.json file. +# list of licenses for packages that don't specify one in their bower.json file package_licenses = { "codemirror-minified": "codemirror-minified", "es6-promise": "es6-promise", @@ -90,15 +92,18 @@ bower_json = collections.OrderedDict() bower_json['name'] = 'bower2bazel-output' bower_json['version'] = '0.0.0' - bower_json['description'] = 'Auto-generated bower.json for dependency management' + bower_json['description'] = 'Auto-generated bower.json for dependency ' + \ + 'management' bower_json['private'] = True bower_json['dependencies'] = {} seeds = set(seeds) for v in version_targets: - path = os.path.join("bazel-out/*-fastbuild/bin", v.lstrip("/").replace(":", "/")) + path = os.path.join("bazel-out/*-fastbuild/bin", + v.lstrip("/").replace(":", "/")) fs = glob.glob(path) - assert len(fs) == 1, '%s: file not found or multiple files found: %s' % (path, fs) + err_msg = '%s: file not found or multiple files found: %s' % (path, fs) + assert len(fs) == 1, err_msg with open(fs[0]) as f: j = json.load(f) if "" in j: @@ -130,8 +135,10 @@ base = subprocess.check_output(["bazel", "info", "output_base"]).strip() exp = os.path.join(decode(base), "external", "bower", "*npm_binary.tgz") fs = sorted(glob.glob(exp)) - assert len(fs) == 1, "bower tarball not found or have multiple versions %s" % fs - return ["python", os.getcwd() + "/tools/js/run_npm_binary.py", sorted(fs)[0]] + args + err_msg = "bower tarball not found or have multiple versions %s" % fs + assert len(fs) == 1, err_msg + return ["python", + os.getcwd() + "/tools/js/run_npm_binary.py", sorted(fs)[0]] + args def main(args): @@ -142,8 +149,9 @@ target_str = subprocess.check_output([ "bazel", "query", "kind(bower_component_bundle, //polygerrit-ui/...)"]) - seed_str = subprocess.check_output([ - "bazel", "query", "attr(seed, 1, kind(bower_component, deps(//polygerrit-ui/...)))"]) + seed_str = subprocess.check_output( + ["bazel", "query", + "attr(seed, 1, kind(bower_component, deps(//polygerrit-ui/...)))"]) targets = [s for s in decode(target_str).split('\n') if s] seeds = [s for s in decode(seed_str).split('\n') if s] prefix = "//lib/js:" @@ -227,7 +235,8 @@ def interpret_bower_json(seeds, ws_out, build_out): - out = subprocess.check_output(["find", "bower_components/", "-name", ".bower.json"]) + out = subprocess.check_output(["find", "bower_components/", "-name", + ".bower.json"]) data = [] for f in sorted(decode(out).split('\n')):
diff --git a/tools/js/bowerutil.py b/tools/js/bowerutil.py index acb0102..9fb82af 100644 --- a/tools/js/bowerutil.py +++ b/tools/js/bowerutil.py
@@ -19,9 +19,9 @@ """Hash the contents of a bower component directory. This is a stable hash of a directory downloaded with `bower install`, minus - the .bower.json file, which is autogenerated each time by bower. Used in lieu - of hashing a zipfile of the contents, since zipfiles are difficult to hash in - a stable manner. + the .bower.json file, which is autogenerated each time by bower. Used in + lieu of hashing a zipfile of the contents, since zipfiles are difficult to + hash in a stable manner. Args: hash_obj: an open hash object, e.g. hashlib.sha1().
diff --git a/tools/js/download_bower.py b/tools/js/download_bower.py index 5a406f2..c9a5df6 100755 --- a/tools/js/download_bower.py +++ b/tools/js/download_bower.py
@@ -39,7 +39,8 @@ cmd = bower_cmd(bower, '-l=error', '-j', 'info', '%s#%s' % (package, version)) try: - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) except: sys.stderr.write("error executing: %s\n" % ' '.join(cmd)) raise @@ -54,14 +55,15 @@ raise ValueError('invalid JSON from %s:\n%s' % (" ".join(cmd), out)) info_name = info.get('name') if info_name != name: - raise ValueError('expected package name %s, got: %s' % (name, info_name)) + raise ValueError( + 'expected package name %s, got: %s' % (name, info_name)) return info def ignore_deps(info): - # Tell bower to ignore dependencies so we just download this component. This - # is just an optimization, since we only pick out the component we need, but - # it's important when downloading sizable dependency trees. + # Tell bower to ignore dependencies so we just download this component. + # This is just an optimization, since we only pick out the component we + # need, but it's important when downloading sizable dependency trees. # # As of 1.6.5 I don't think ignoredDependencies can be specified on the # command line with --config, so we have to create .bowerrc. @@ -99,7 +101,8 @@ info = bower_info(opts.b, opts.n, opts.p, opts.v) ignore_deps(info) subprocess.check_call( - bower_cmd(opts.b, '--quiet', 'install', '%s#%s' % (opts.p, opts.v))) + bower_cmd( + opts.b, '--quiet', 'install', '%s#%s' % (opts.p, opts.v))) bc = os.path.join(cwd, 'bower_components') subprocess.check_call( ['zip', '-q', '--exclude', '.bower.json', '-r', cached, opts.n], @@ -107,17 +110,20 @@ if opts.s: path = os.path.join(bc, opts.n) - sha1 = bowerutil.hash_bower_component(hashlib.sha1(), path).hexdigest() + sha1 = bowerutil.hash_bower_component( + hashlib.sha1(), path).hexdigest() if opts.s != sha1: print(( '%s#%s:\n' 'expected %s\n' - 'received %s\n') % (opts.p, opts.v, opts.s, sha1), file=sys.stderr) + 'received %s\n') % (opts.p, opts.v, opts.s, sha1), + file=sys.stderr) try: os.remove(cached) except OSError as err: if path.exists(cached): - print('error removing %s: %s' % (cached, err), file=sys.stderr) + print('error removing %s: %s' % (cached, err), + file=sys.stderr) return 1 shutil.copyfile(cached, outzip)
diff --git a/tools/js/npm_pack.py b/tools/js/npm_pack.py index 5433ef5..d817701 100755 --- a/tools/js/npm_pack.py +++ b/tools/js/npm_pack.py
@@ -56,7 +56,7 @@ filename = '%s-%s.tgz' % (name, version) url = 'http://registry.npmjs.org/%s/-/%s' % (name, filename) - tmpdir = tempfile.mkdtemp(); + tmpdir = tempfile.mkdtemp() tgz = os.path.join(tmpdir, filename) atexit.register(lambda: shutil.rmtree(tmpdir))
diff --git a/tools/js/run_npm_binary.py b/tools/js/run_npm_binary.py index eb3b228..dfcdaca 100644 --- a/tools/js/run_npm_binary.py +++ b/tools/js/run_npm_binary.py
@@ -54,8 +54,8 @@ for mem in tar.getmembers(): if mem.name != bin: extract_one(mem) - # Extract bin last so other processes only short circuit when extraction is - # finished. + # Extract bin last so other processes only short circuit when + # extraction is finished. extract_one(tar.getmember(bin)) @@ -72,7 +72,8 @@ name, _ = parts - # Avoid importing from gerrit because we don't want to depend on the right CWD. + # Avoid importing from gerrit because we don't want to depend on the right + # working directory sha1 = hashlib.sha1(open(path, 'rb').read()).hexdigest() outdir = '%s-%s' % (path[:-len(suffix)], sha1) rel_bin = os.path.join('package', 'bin', name)
diff --git a/tools/maven/mvn.py b/tools/maven/mvn.py index 3fa5530..d47d027 100755 --- a/tools/maven/mvn.py +++ b/tools/maven/mvn.py
@@ -56,7 +56,8 @@ for spec in args.s: artifact, packaging_type, src = spec.split(':') exe = cmd + [ - '-DpomFile=%s' % path.join(root, 'tools', 'maven', '%s_pom.xml' % artifact), + '-DpomFile=%s' % path.join(root, 'tools', 'maven', + '%s_pom.xml' % artifact), '-Dpackaging=%s' % packaging_type, '-Dfile=%s' % src, ]
diff --git a/tools/merge_jars.py b/tools/merge_jars.py index 8050f75..6b46069 100755 --- a/tools/merge_jars.py +++ b/tools/merge_jars.py
@@ -17,7 +17,6 @@ import collections import sys import zipfile -import io if len(sys.argv) < 3: print('usage: %s <out.zip> <in.zip>...' % sys.argv[0], file=sys.stderr)
diff --git a/tools/util.py b/tools/util.py index e35355d..45d0541 100644 --- a/tools/util.py +++ b/tools/util.py
@@ -16,10 +16,12 @@ REPO_ROOTS = { 'GERRIT': 'http://gerrit-maven.storage.googleapis.com', - 'GERRIT_API': 'https://gerrit-api.commondatastorage.googleapis.com/release', + 'GERRIT_API': + 'https://gerrit-api.commondatastorage.googleapis.com/release', 'MAVEN_CENTRAL': 'http://repo1.maven.org/maven2', 'MAVEN_LOCAL': 'file://' + path.expanduser('~/.m2/repository'), - 'MAVEN_SNAPSHOT': 'https://oss.sonatype.org/content/repositories/snapshots', + 'MAVEN_SNAPSHOT': + 'https://oss.sonatype.org/content/repositories/snapshots', }
diff --git a/tools/util_test.py b/tools/util_test.py index 8af3231..fa67696 100644 --- a/tools/util_test.py +++ b/tools/util_test.py
@@ -24,7 +24,8 @@ def testKnown(self): url = resolve_url('GERRIT:foo.jar', {}) - self.assertEqual(url, 'http://gerrit-maven.storage.googleapis.com/foo.jar') + self.assertEqual(url, + 'http://gerrit-maven.storage.googleapis.com/foo.jar') def testKnownRedirect(self): url = resolve_url('MAVEN_CENTRAL:foo.jar', @@ -37,7 +38,8 @@ def testCustomRedirect(self): url = resolve_url('MAVEN_EXAMPLE:foo.jar', - {'MAVEN_EXAMPLE': 'http://maven.example.com/release'}) + {'MAVEN_EXAMPLE': + 'http://maven.example.com/release'}) self.assertEqual(url, 'http://maven.example.com/release/foo.jar')