Commit a138f082 authored by Gavin Mak's avatar Gavin Mak Committed by LUCI CQ

Add python3 support to gitiles recipe module

This change omits python3 support for resources/gerrit_client.py

Bug: 1227140
Change-Id: Ibc8d9f1fbd28008959991688ced5818f0188f905
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3012233
Commit-Queue: Anthony Polito <apolito@google.com>
Reviewed-by: 's avatarAnthony Polito <apolito@google.com>
parent 0e27bfe3
...@@ -588,16 +588,16 @@ DEPRECATED. Consider using gerrit.get_change_description instead. ...@@ -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] [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. Module for polling a git repository using the Gitiles web interface.
&mdash; **def [canonicalize\_repo\_url](/recipes/recipe_modules/gitiles/api.py#216)(self, repo_url):** &mdash; **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. Returns a canonical form of repo_url. If not recognized, returns as is.
&mdash; **def [commit\_log](/recipes/recipe_modules/gitiles/api.py#114)(self, url, commit, step_name=None, attempts=None):** &mdash; **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. Returns: (dict) the Gitiles commit log structure for a given commit.
...@@ -607,7 +607,7 @@ Args: ...@@ -607,7 +607,7 @@ Args:
* step_name (str): If not None, override the step name. * step_name (str): If not None, override the step name.
* attempts (int): Number of times to try the request before failing. * attempts (int): Number of times to try the request before failing.
&mdash; **def [download\_archive](/recipes/recipe_modules/gitiles/api.py#156)(self, repository_url, destination, revision='refs/heads/master'):** &mdash; **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`. Downloads an archive of the repo and extracts it to `destination`.
...@@ -623,7 +623,7 @@ Args: ...@@ -623,7 +623,7 @@ Args:
* revision (str): The ref or revision in the repo to download. Defaults to * revision (str): The ref or revision in the repo to download. Defaults to
'refs/heads/master'. 'refs/heads/master'.
&mdash; **def [download\_file](/recipes/recipe_modules/gitiles/api.py#130)(self, repository_url, file_path, branch='master', step_name=None, attempts=None, \*\*kwargs):** &mdash; **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. Downloads raw file content from a Gitiles repository.
...@@ -637,7 +637,7 @@ Args: ...@@ -637,7 +637,7 @@ Args:
Returns: Returns:
Raw file content. Raw file content.
&mdash; **def [log](/recipes/recipe_modules/gitiles/api.py#68)(self, url, ref, limit=0, cursor=None, step_name=None, attempts=None, \*\*kwargs):** &mdash; **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. Returns the most recent commits under the given ref with properties.
...@@ -660,17 +660,17 @@ Returns: ...@@ -660,17 +660,17 @@ Returns:
Cursor can be used for subsequent calls to log for paging. If None, Cursor can be used for subsequent calls to log for paging. If None,
signals that there are no more commits to fetch. signals that there are no more commits to fetch.
&mdash; **def [parse\_repo\_url](/recipes/recipe_modules/gitiles/api.py#205)(self, repo_url):** &mdash; **def [parse\_repo\_url](/recipes/recipe_modules/gitiles/api.py#211)(self, repo_url):**
Returns (host, project) pair. Returns (host, project) pair.
Returns (None, None) if repo_url is not recognized. Returns (None, None) if repo_url is not recognized.
&mdash; **def [refs](/recipes/recipe_modules/gitiles/api.py#56)(self, url, step_name='refs', attempts=None):** &mdash; **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. Returns a list of refs in the remote repository.
&mdash; **def [unparse\_repo\_url](/recipes/recipe_modules/gitiles/api.py#212)(self, host, project):** &mdash; **def [unparse\_repo\_url](/recipes/recipe_modules/gitiles/api.py#218)(self, host, project):**
Generates a Gitiles repo URL. See also parse_repo_url. Generates a Gitiles repo URL. See also parse_repo_url.
### *recipe_modules* / [gsutil](/recipes/recipe_modules/gsutil) ### *recipe_modules* / [gsutil](/recipes/recipe_modules/gsutil)
......
...@@ -2,8 +2,14 @@ ...@@ -2,8 +2,14 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
from __future__ import division
import base64 import base64
import urlparse
try:
import urlparse
except ImportError: # pragma: no cover
import urllib.parse as urlparse
from recipe_engine import recipe_api from recipe_engine import recipe_api
......
...@@ -10,6 +10,8 @@ Example usage: ...@@ -10,6 +10,8 @@ Example usage:
-u https://chromium.googlesource.com/chromium/src/+log -u https://chromium.googlesource.com/chromium/src/+log
""" """
from __future__ import print_function
import argparse import argparse
import json import json
import logging import logging
...@@ -17,8 +19,13 @@ import os ...@@ -17,8 +19,13 @@ import os
import sys import sys
import tarfile import tarfile
import time 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( DEPOT_TOOLS = os.path.abspath(
os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir,
...@@ -35,7 +42,7 @@ def reparse_url(parsed_url, query_params): ...@@ -35,7 +42,7 @@ def reparse_url(parsed_url, query_params):
path=parsed_url.path, path=parsed_url.path,
params=parsed_url.params, params=parsed_url.params,
fragment=parsed_url.fragment, fragment=parsed_url.fragment,
query=urllib.urlencode(query_params, doseq=True)) query=urlencode(query_params, doseq=True))
def gitiles_get(parsed_url, handler, attempts): def gitiles_get(parsed_url, handler, attempts):
......
...@@ -25,7 +25,7 @@ class GitilesTestApi(recipe_test_api.RecipeTestApi): ...@@ -25,7 +25,7 @@ class GitilesTestApi(recipe_test_api.RecipeTestApi):
new_files=['%s.py' % (chr(i + ord('a')))], new_files=['%s.py' % (chr(i + ord('a')))],
email='fake_%s@fake_%i.email.com' % (s, i), email='fake_%s@fake_%i.email.com' % (s, i),
) )
for i in xrange(n) for i in range(n)
], ],
} }
if cursor: if cursor:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment