build: Fix pylint 2.10 issues, use python3 where possible
The newest pylint release complained about several issues that the older release did not. This resolves those issues: - removes unneeded "u" prefix from strings - adds "encoding" parameter for all open() calls - because "encoding" is a python3-only parameter, use python3 in all the scripts that we control Unfortunately, python2 is required for any scripts that import modules from the ancient Chromium build system we're using (referenced by DEPS), as well as kokoro scripts. Change-Id: I2e9f97af508efe58b5a71de21740e59b1528affd
This commit is contained in:
parent
6cbc797ccc
commit
ac125564b9
|
@ -54,18 +54,18 @@ source_suffix = ['.rst', '.md']
|
||||||
master_doc = 'index'
|
master_doc = 'index'
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = u'Shaka Packager'
|
project = 'Shaka Packager'
|
||||||
copyright = u'2017, Google' # pylint: disable=redefined-builtin
|
copyright = '2017, Google' # pylint: disable=redefined-builtin
|
||||||
author = u'Google'
|
author = 'Google'
|
||||||
|
|
||||||
# The version info for the project you're documenting, acts as replacement for
|
# The version info for the project you're documenting, acts as replacement for
|
||||||
# |version| and |release|, also used in various other places throughout the
|
# |version| and |release|, also used in various other places throughout the
|
||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
# version = u'2.0'
|
# version = '2.0'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
# release = u'2.0'
|
# release = '2.0'
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
@ -150,8 +150,8 @@ latex_elements = {
|
||||||
# (source start file, target name, title,
|
# (source start file, target name, title,
|
||||||
# author, documentclass [howto, manual, or own class]).
|
# author, documentclass [howto, manual, or own class]).
|
||||||
latex_documents = [
|
latex_documents = [
|
||||||
(master_doc, 'ShakaPackager.tex', u'Shaka Packager Documentation',
|
(master_doc, 'ShakaPackager.tex', 'Shaka Packager Documentation',
|
||||||
u'Google', 'manual'),
|
'Google', 'manual'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ latex_documents = [
|
||||||
# One entry per manual page. List of tuples
|
# One entry per manual page. List of tuples
|
||||||
# (source start file, name, description, authors, manual section).
|
# (source start file, name, description, authors, manual section).
|
||||||
man_pages = [
|
man_pages = [
|
||||||
(master_doc, 'shakapackager', u'Shaka Packager Documentation',
|
(master_doc, 'shakapackager', 'Shaka Packager Documentation',
|
||||||
[author], 1)
|
[author], 1)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ man_pages = [
|
||||||
# (source start file, target name, title, author,
|
# (source start file, target name, title, author,
|
||||||
# dir menu entry, description, category)
|
# dir menu entry, description, category)
|
||||||
texinfo_documents = [
|
texinfo_documents = [
|
||||||
(master_doc, 'ShakaPackager', u'Shaka Packager Documentation',
|
(master_doc, 'ShakaPackager', 'Shaka Packager Documentation',
|
||||||
author, 'ShakaPackager', 'One line description of project.',
|
author, 'ShakaPackager', 'One line description of project.',
|
||||||
'Miscellaneous'),
|
'Miscellaneous'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
#
|
#
|
||||||
# Copyright 2014 Google Inc. All rights reserved.
|
# Copyright 2014 Google Inc. All rights reserved.
|
||||||
#
|
#
|
||||||
|
@ -26,8 +26,6 @@ Step 1 is only required if there is any gyp file change. Otherwise, you
|
||||||
may just run ninja.
|
may just run ninja.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,10 @@ Usage:
|
||||||
this_script.py search_text replacement_text
|
this_script.py search_text replacement_text
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# This runs on a Windows kokoro host where we don't control the python version.
|
||||||
|
# Because this runs in python2, we can't specify an encoding in open().
|
||||||
|
# pylint: disable=unspecified-encoding
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
|
@ -169,10 +169,10 @@ class DiffFilesPolicy(object):
|
||||||
dump_b = os.path.join(out_dir, os.path.basename(file_b) + '.dump.actual')
|
dump_b = os.path.join(out_dir, os.path.basename(file_b) + '.dump.actual')
|
||||||
try:
|
try:
|
||||||
cmd = ['mp4dump', '--verbosity', '2', file_a]
|
cmd = ['mp4dump', '--verbosity', '2', file_a]
|
||||||
with open(dump_a, 'w') as f:
|
with open(dump_a, 'w', encoding='utf8') as f:
|
||||||
subprocess.check_call(cmd, stdout=f)
|
subprocess.check_call(cmd, stdout=f)
|
||||||
cmd = ['mp4dump', '--verbosity', '2', file_b]
|
cmd = ['mp4dump', '--verbosity', '2', file_b]
|
||||||
with open(dump_b, 'w') as f:
|
with open(dump_b, 'w', encoding='utf8') as f:
|
||||||
subprocess.check_call(cmd, stdout=f)
|
subprocess.check_call(cmd, stdout=f)
|
||||||
except (OSError, subprocess.CalledProcessError):
|
except (OSError, subprocess.CalledProcessError):
|
||||||
# If the program isn't available or returns an error, just ignore it and
|
# If the program isn't available or returns an error, just ignore it and
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
'<(protoc)',
|
'<(protoc)',
|
||||||
],
|
],
|
||||||
'action': [
|
'action': [
|
||||||
'python',
|
'python3',
|
||||||
'<(protoc_wrapper)',
|
'<(protoc_wrapper)',
|
||||||
# If no cc_include specified --protobuf option will be ignored.
|
# If no cc_include specified --protobuf option will be ignored.
|
||||||
'--include',
|
'--include',
|
||||||
|
|
|
@ -428,7 +428,7 @@
|
||||||
'<(shared_generated_dir)/x86insn_nasm.gperf',
|
'<(shared_generated_dir)/x86insn_nasm.gperf',
|
||||||
],
|
],
|
||||||
'action': [
|
'action': [
|
||||||
'python',
|
'python3',
|
||||||
'<(gen_insn_path)',
|
'<(gen_insn_path)',
|
||||||
'<(shared_generated_dir)',
|
'<(shared_generated_dir)',
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
#
|
#
|
||||||
# Copyright 2018 Google Inc. All rights reserved.
|
# Copyright 2018 Google Inc. All rights reserved.
|
||||||
#
|
#
|
||||||
|
@ -7,8 +7,6 @@
|
||||||
# https://developers.google.com/open-source/licenses/bsd
|
# https://developers.google.com/open-source/licenses/bsd
|
||||||
"""This script extracts a version or release notes from the changelog."""
|
"""This script extracts a version or release notes from the changelog."""
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
@ -22,7 +20,7 @@ def main():
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
with open('CHANGELOG.md', 'r') as f:
|
with open('CHANGELOG.md', 'r', encoding='utf8') as f:
|
||||||
contents = f.read()
|
contents = f.read()
|
||||||
|
|
||||||
# This excludes the header line with the release name and date, to match the
|
# This excludes the header line with the release name and date, to match the
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
#
|
#
|
||||||
# Copyright 2018 Google Inc. All rights reserved.
|
# Copyright 2018 Google Inc. All rights reserved.
|
||||||
#
|
#
|
||||||
|
@ -134,11 +134,11 @@ def GenerateLicenseNotice(output_dir, output_license_file_name):
|
||||||
|
|
||||||
if output_dir:
|
if output_dir:
|
||||||
cc_file_path = os.path.join(output_dir, 'license_notice.cc')
|
cc_file_path = os.path.join(output_dir, 'license_notice.cc')
|
||||||
with open(cc_file_path, 'w') as output:
|
with open(cc_file_path, 'w', encoding='utf8') as output:
|
||||||
output.write(CC_FILE_TEMPLATE.format(content_array_text))
|
output.write(CC_FILE_TEMPLATE.format(content_array_text))
|
||||||
|
|
||||||
h_file_path = os.path.join(output_dir, 'license_notice.h')
|
h_file_path = os.path.join(output_dir, 'license_notice.h')
|
||||||
with open(h_file_path, 'w') as output:
|
with open(h_file_path, 'w', encoding='utf8') as output:
|
||||||
output.write(H_FILE_TEMPLATE.format(len(content)))
|
output.write(H_FILE_TEMPLATE.format(len(content)))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,6 @@ Steps to install clang-format on your system if you don't have it already:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
'<(generated_dir)/license_notice.h',
|
'<(generated_dir)/license_notice.h',
|
||||||
],
|
],
|
||||||
'action': [
|
'action': [
|
||||||
'python', 'generate_license_notice.py', '<(generated_dir)',
|
'python3', 'generate_license_notice.py', '<(generated_dir)',
|
||||||
],
|
],
|
||||||
'process_outputs_as_sources': 1,
|
'process_outputs_as_sources': 1,
|
||||||
'message': 'Generating embeddable license',
|
'message': 'Generating embeddable license',
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
# https://developers.google.com/open-source/licenses/bsd
|
# https://developers.google.com/open-source/licenses/bsd
|
||||||
"""This script is used to generate version string for packager."""
|
"""This script is used to generate version string for packager."""
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -29,4 +27,4 @@ if __name__ == '__main__':
|
||||||
if version_tag:
|
if version_tag:
|
||||||
print('{0}-{1}'.format(version_tag, version_hash))
|
print('{0}-{1}'.format(version_tag, version_hash))
|
||||||
else:
|
else:
|
||||||
print(version_hash)
|
print(version_hash.decode('utf8'))
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
'target_name': 'version',
|
'target_name': 'version',
|
||||||
'type': '<(component)',
|
'type': '<(component)',
|
||||||
'defines': [
|
'defines': [
|
||||||
'PACKAGER_VERSION="<!(python generate_version_string.py)"',
|
'PACKAGER_VERSION="<!(python3 generate_version_string.py)"',
|
||||||
],
|
],
|
||||||
'sources': [
|
'sources': [
|
||||||
'version.cc',
|
'version.cc',
|
||||||
|
|
Loading…
Reference in New Issue