All __future__ imports (unicode_literals, print_function) are already
mandatory in py3. Also remove an outdated py2 comment in
presubmit_canned_checks.py
Bug: 1475402
Change-Id: I27cf6a8268f6dd1081f22af782c4c29a975376ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4867135
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Leave the recipes/ code at 2 space to match the rest of the recipes
project in other repos.
Reformatted using:
files=( $(
git ls-tree -r --name-only HEAD | \
grep -Ev -e '^(third_party|recipes)/' | \
grep '\.py$';
git grep -l '#!/usr/bin/env.*python' | grep -v '\.py$'
) )
parallel ./yapf -i -- "${files[@]}"
~/chromiumos/chromite/contrib/reflow_overlong_comments "${files[@]}"
The files that still had strings that were too long were manually
reformatted because they were easy and only a few issues.
autoninja.py
clang_format.py
download_from_google_storage.py
fix_encoding.py
gclient_utils.py
git_cache.py
git_common.py
git_map_branches.py
git_reparent_branch.py
gn.py
my_activity.py
owners_finder.py
presubmit_canned_checks.py
reclient_helper.py
reclientreport.py
roll_dep.py
rustfmt.py
siso.py
split_cl.py
subcommand.py
subprocess2.py
swift_format.py
upload_to_google_storage.py
These files still had lines (strings) that were too long, so the pylint
warnings were suppressed with a TODO.
auth.py
gclient.py
gclient_eval.py
gclient_paths.py
gclient_scm.py
gerrit_util.py
git_cl.py
presubmit_canned_checks.py
presubmit_support.py
scm.py
Change-Id: Ia6535c4f2c48d46b589ec1e791dde6c6b2ea858f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4836379
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
python3 is the only supported version of python in depot_tools.
Remove py2 support from files including:
* cpplint.py
* subprocess2.py
* many tests and testing_support files
Bug: 1475402
Change-Id: I67a98188bc13c4dc119e6158a37bd236bfd6ea70
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4824474
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Scott Lee <ddoman@chromium.org>
When running "git cl presubmit --all" some of the presubmit messages
were ending up double-spaced if the output is sent to a file and then
loaded into notepad or Visual Studio. Visual Studio would complain
about inconsistent line endings, and it turns out that this was all
caused by some lines having \r\r\n line endings - notepad and Visual
Studio interpret that as two line endings.
The problem is that the stream that WinUnicodeOutput writes to does \n
to \r\n translation. If the text being printed already has \r\n line
endings then we get doubled-up \r characters. The fix is to replace all
\r\n sequences with \n before calling write.
This reduces the line count of the output by almost 2300 lines (more
than 25% of the total) and makes it much more readable.
Bug: 1309977
Change-Id: Ie5475087badc3d3146e4f2ba41d30c9817dd375a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3589498
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
This reverts commit 20815505e6.
Reason for revert:
This is not necessary after https://crrev.com/c/1929653
Original change's description:
> Modify fix_encodng to make it use fix_win_sys_argv for python2 only and
> not for python3 on windows.
>
> The function works around <https://bugs.python.org/issue2128>, and the bug is fixed for python3 now.
>
> Bug: 1182016
> Change-Id: I3880843b109d5b9779e5bbd1e39a3132f925ecc4
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2738234
> Commit-Queue: Momo Sasaki <momosasaki@google.com>
> Reviewed-by: Dirk Pranke <dpranke@google.com>
> Reviewed-by: Junji Watanabe <jwata@google.com>
> Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Bug: 1182016
Change-Id: I153640b174a78990e39b3597208b6785003ca321
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2738936
Reviewed-by: Junji Watanabe <jwata@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
not for python3 on windows.
The function works around <https://bugs.python.org/issue2128>, and the bug is fixed for python3 now.
Bug: 1182016
Change-Id: I3880843b109d5b9779e5bbd1e39a3132f925ecc4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2738234
Commit-Queue: Momo Sasaki <momosasaki@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Reviewed-by: Junji Watanabe <jwata@google.com>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
This was made by running `codespell` and `scspell`
and then checking the results.
Change-Id: I169fd5b40294f83015075b4a899fbca263821f25
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2144602
Commit-Queue: Quinten Yearsley <qyearsley@chromium.org>
Auto-Submit: Quinten Yearsley <qyearsley@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Strings need to be passed to WriteConsoleW, otherwise an exception will be thrown:
<Unicode console <stdout>>.write: ArgumentError("argument 2: <class 'TypeError'>: wrong type")
Traceback (most recent call last):
File "C:\Google\depot_tools\metrics.py", line 267, in print_notice_and_exit
yield
File "C:\Google\depot_tools\gclient.py", line 3156, in <module>
sys.exit(main(sys.argv[1:]))
File "C:\Google\depot_tools\gclient.py", line 3142, in main
return dispatcher.execute(OptionParser(), argv)
File "C:\Google\depot_tools\subcommand.py", line 252, in execute
return command(parser, args[1:])
File "C:\Google\depot_tools\gclient.py", line 2699, in CMDsync
ret = client.RunOnDeps('update', args)
File "C:\Google\depot_tools\gclient.py", line 1771, in RunOnDeps
self.RunHooksRecursively(self._options, pm)
File "C:\Google\depot_tools\gclient.py", line 1064, in RunHooksRecursively
hook.run()
File "C:\Google\depot_tools\gclient.py", line 255, in run
gclient_utils.CheckCallAndFilter(
File "C:\Google\depot_tools\gclient_utils.py", line 592, in CheckCallAndFilter
stdout_write(in_byte)
File "C:\Google\depot_tools\gclient_utils.py", line 375, in write
return self._wrapped.write(out)
File "C:\Google\depot_tools\gclient_utils.py", line 343, in write
self._wrapped.write(out, *args, **kwargs)
File "C:\Google\depot_tools\fix_encoding.py", line 224, in write
retval = self._WriteConsoleW(
ctypes.ArgumentError: argument 2: <class 'TypeError'>: wrong type
Bug: 984182
Change-Id: Icffe0e0ea1fe2be5bc7607e32f58605d02f1f870
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1778746
Commit-Queue: Raul Tambre <raul@tambre.ee>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Auto-Submit: Raul Tambre <raul@tambre.ee>
The unicode type doesn't exist in Python 3, because everything's Unicode.
This would resulted in the following error on Python 3:
<Unicode console <stderr>>.write: NameError("name 'unicode' is not defined")
Bug: 942522
Change-Id: I3e90d078df64abcec2c79aa69881deea40ff7d01
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1701401
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Raul Tambre <raul@tambre.ee>
Auto-Submit: Raul Tambre <raul@tambre.ee>
Ran "2to3 -w -n -f print ./" and manually added imports.
Ran "^\s*print " and "\s+print " to find batch/shell scripts, comments and the like with embedded code, and updated them manually.
Also manually added imports to files, which used print as a function, but were missing the import.
The scripts still work with Python 2.
There are no intended behaviour changes.
Bug: 942522
Change-Id: Id777e4d4df4adcdfdab1b18bde89f235ef491b9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1595684
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
Auto-Submit: Raul Tambre <raul@tambre.ee>
This enables gclient sync and gclient runhooks to run, barring hook script failures.
git cl upload also now works.
The scripts still work with Python 2.
There are no intended behaviour changes.
Bug: 942522
Change-Id: I2ac587b5f803ba7f5bb5e412337ce049f4b1a741
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1524583
Commit-Queue: Raul Tambre <raul@tambre.ee>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
This affects a bunch of files, but only changes comments,
and shouldn't make any difference to behavior.
The purpose is to slightly improve readability of pylint
disable comments.
Change-Id: Ic6cd0f8de792b31d91c6125f6da2616450b30f11
Reviewed-on: https://chromium-review.googlesource.com/420412
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Quinten Yearsley <qyearsley@chromium.org>
With this change, fix_encoding can be imported in python3.
fix_encoding.fix_encoding() returns False because, at least on my Ubuntu 14.04
system running python 3.4.3;
sys.getdefaultencoding() == 'utf-8'
The Windows specific code hasn't been tested on python3 and is expected to
require fixes.
R=vapier@chromium.org
BUG=61357
Review URL: https://codereview.chromium.org/1710553003
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@298834 0039d316-1c4b-4281-b951-d872f2087c98
The reason of this change (beside deleting 30 lines) is to fix pylint on Mac.
For an unknown reason, it was dying here trying to process the minidom import.
R=dpranke@chromium.org
BUG=
TEST=
Review URL: http://codereview.chromium.org/6799021
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@80770 0039d316-1c4b-4281-b951-d872f2087c98
with python 2.5.1.
Traceback (most recent call last):
File "/Users/tc/depot_tools/gclient.py", line 1270, in <module>
fix_encoding.fix_encoding()
File "/Users/tc/depot_tools/fix_encoding.py", line 350, in fix_encoding
ret &= fix_default_encoding()
File "/Users/tc/depot_tools/fix_encoding.py", line 51, in
fix_default_encoding
lang = locale.getlocale(aref)[0]
File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py",
line 460, in getlocale
return _parse_localename(localename)
File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py",
line 373, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: C/UTF-8/C/C/C/C
R=dpranke@chromium.org,chase@chromium.org,bradnelson@google.com,maruel@chromium.org,evan@chromium.org,nsylvain@chromium.org,nsylvain@google.com
Review URL: http://codereview.chromium.org/6730008
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@79213 0039d316-1c4b-4281-b951-d872f2087c98
Reapply r79006 with fixes for ubuntu 10.4.
The only change is in fix_default_encoding() to trap an exception
locale.getlocale() may throw.
R=dpranke@chromium.org
BUG=none
TEST=unit test
Review URL: http://codereview.chromium.org/6721029
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@79144 0039d316-1c4b-4281-b951-d872f2087c98
It is causing exception for some users on ubuntu 10.4 with:
"category LC_ALL is not supported"
TBR=dpranke
Review URL: http://codereview.chromium.org/6717025
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@79012 0039d316-1c4b-4281-b951-d872f2087c98
With this code in action, I can successfully print arabic and chinese on linux
and cygwin. It fails to print chinese on my Mac but prints arabic. It prints '?'
on Windows console but it *doesn't throw* which is the biggest improvement here.
It was particularly a problem on windows because WindowsError's description text
is in the current ANSI code page so it failed to print if the text was not pure
ASCII, like error message when using Windows' French UI.
R=dpranke@chromium.org
BUG=none
TEST=manual unit test ./tests/fix_encoding_test.py and it shouldn't throw
Review URL: http://codereview.chromium.org/6676090
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@79006 0039d316-1c4b-4281-b951-d872f2087c98