diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index be01959ca2..8dd48e5e7c 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -588,16 +588,16 @@ DEPRECATED. Consider using gerrit.get_change_description instead. [DEPS](/recipes/recipe_modules/gitiles/__init__.py#5): [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/python][recipe_engine/recipe_modules/python], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/step][recipe_engine/recipe_modules/step], [recipe\_engine/url][recipe_engine/recipe_modules/url] -#### **class [Gitiles](/recipes/recipe_modules/gitiles/api.py#11)([RecipeApi][recipe_engine/wkt/RecipeApi]):** +#### **class [Gitiles](/recipes/recipe_modules/gitiles/api.py#17)([RecipeApi][recipe_engine/wkt/RecipeApi]):** Module for polling a git repository using the Gitiles web interface. -— **def [canonicalize\_repo\_url](/recipes/recipe_modules/gitiles/api.py#216)(self, repo_url):** +— **def [canonicalize\_repo\_url](/recipes/recipe_modules/gitiles/api.py#222)(self, repo_url):** Returns a canonical form of repo_url. If not recognized, returns as is. -— **def [commit\_log](/recipes/recipe_modules/gitiles/api.py#114)(self, url, commit, step_name=None, attempts=None):** +— **def [commit\_log](/recipes/recipe_modules/gitiles/api.py#120)(self, url, commit, step_name=None, attempts=None):** Returns: (dict) the Gitiles commit log structure for a given commit. @@ -607,7 +607,7 @@ Args: * step_name (str): If not None, override the step name. * attempts (int): Number of times to try the request before failing. -— **def [download\_archive](/recipes/recipe_modules/gitiles/api.py#156)(self, repository_url, destination, revision='refs/heads/master'):** +— **def [download\_archive](/recipes/recipe_modules/gitiles/api.py#162)(self, repository_url, destination, revision='refs/heads/master'):** Downloads an archive of the repo and extracts it to `destination`. @@ -623,7 +623,7 @@ Args: * revision (str): The ref or revision in the repo to download. Defaults to 'refs/heads/master'. -— **def [download\_file](/recipes/recipe_modules/gitiles/api.py#130)(self, repository_url, file_path, branch='master', step_name=None, attempts=None, \*\*kwargs):** +— **def [download\_file](/recipes/recipe_modules/gitiles/api.py#136)(self, repository_url, file_path, branch='master', step_name=None, attempts=None, \*\*kwargs):** Downloads raw file content from a Gitiles repository. @@ -637,7 +637,7 @@ Args: Returns: Raw file content. -— **def [log](/recipes/recipe_modules/gitiles/api.py#68)(self, url, ref, limit=0, cursor=None, step_name=None, attempts=None, \*\*kwargs):** +— **def [log](/recipes/recipe_modules/gitiles/api.py#74)(self, url, ref, limit=0, cursor=None, step_name=None, attempts=None, \*\*kwargs):** Returns the most recent commits under the given ref with properties. @@ -660,17 +660,17 @@ Returns: Cursor can be used for subsequent calls to log for paging. If None, signals that there are no more commits to fetch. -— **def [parse\_repo\_url](/recipes/recipe_modules/gitiles/api.py#205)(self, repo_url):** +— **def [parse\_repo\_url](/recipes/recipe_modules/gitiles/api.py#211)(self, repo_url):** Returns (host, project) pair. Returns (None, None) if repo_url is not recognized. -— **def [refs](/recipes/recipe_modules/gitiles/api.py#56)(self, url, step_name='refs', attempts=None):** +— **def [refs](/recipes/recipe_modules/gitiles/api.py#62)(self, url, step_name='refs', attempts=None):** Returns a list of refs in the remote repository. -— **def [unparse\_repo\_url](/recipes/recipe_modules/gitiles/api.py#212)(self, host, project):** +— **def [unparse\_repo\_url](/recipes/recipe_modules/gitiles/api.py#218)(self, host, project):** Generates a Gitiles repo URL. See also parse_repo_url. ### *recipe_modules* / [gsutil](/recipes/recipe_modules/gsutil) diff --git a/recipes/recipe_modules/gitiles/api.py b/recipes/recipe_modules/gitiles/api.py index ab46fd1c43..d8cb4b2a18 100644 --- a/recipes/recipe_modules/gitiles/api.py +++ b/recipes/recipe_modules/gitiles/api.py @@ -2,8 +2,14 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +from __future__ import division + import base64 -import urlparse + +try: + import urlparse +except ImportError: # pragma: no cover + import urllib.parse as urlparse from recipe_engine import recipe_api diff --git a/recipes/recipe_modules/gitiles/resources/gerrit_client.py b/recipes/recipe_modules/gitiles/resources/gerrit_client.py index 04d3cc643a..a4ad62e099 100755 --- a/recipes/recipe_modules/gitiles/resources/gerrit_client.py +++ b/recipes/recipe_modules/gitiles/resources/gerrit_client.py @@ -10,6 +10,8 @@ Example usage: -u https://chromium.googlesource.com/chromium/src/+log """ +from __future__ import print_function + import argparse import json import logging @@ -17,8 +19,13 @@ import os import sys import tarfile import time -import urllib -import urlparse + +try: + from urllib import urlencode + import urlparse +except ImportError: # pragma: no cover + from urllib.parse import urlencode + import urllib.parse as urlparse DEPOT_TOOLS = os.path.abspath( os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, @@ -35,7 +42,7 @@ def reparse_url(parsed_url, query_params): path=parsed_url.path, params=parsed_url.params, fragment=parsed_url.fragment, - query=urllib.urlencode(query_params, doseq=True)) + query=urlencode(query_params, doseq=True)) def gitiles_get(parsed_url, handler, attempts): diff --git a/recipes/recipe_modules/gitiles/test_api.py b/recipes/recipe_modules/gitiles/test_api.py index 0f10f32dcd..1e6f6c35b7 100644 --- a/recipes/recipe_modules/gitiles/test_api.py +++ b/recipes/recipe_modules/gitiles/test_api.py @@ -25,7 +25,7 @@ class GitilesTestApi(recipe_test_api.RecipeTestApi): new_files=['%s.py' % (chr(i + ord('a')))], email='fake_%s@fake_%i.email.com' % (s, i), ) - for i in xrange(n) + for i in range(n) ], } if cursor: