The following issues were found
script/add-debug-link.py
32 issues
Line: 1
Column: 1
#!/usr/bin/env python
from __future__ import print_function
import argparse
import os
import sys
from lib.config import LINUX_BINARIES, PLATFORM
from lib.util import execute, get_out_dir
Reported by Pylint.
Line: 1
Column: 1
#!/usr/bin/env python
from __future__ import print_function
import argparse
import os
import sys
from lib.config import LINUX_BINARIES, PLATFORM
from lib.util import execute, get_out_dir
Reported by Pylint.
Line: 10
Column: 1
from lib.config import LINUX_BINARIES, PLATFORM
from lib.util import execute, get_out_dir
def add_debug_link_into_binaries(directory, target_cpu, debug_dir):
for binary in LINUX_BINARIES:
binary_path = os.path.join(directory, binary)
if os.path.isfile(binary_path):
add_debug_link_into_binary(binary_path, target_cpu, debug_dir)
Reported by Pylint.
Line: 11
Column: 1
from lib.util import execute, get_out_dir
def add_debug_link_into_binaries(directory, target_cpu, debug_dir):
for binary in LINUX_BINARIES:
binary_path = os.path.join(directory, binary)
if os.path.isfile(binary_path):
add_debug_link_into_binary(binary_path, target_cpu, debug_dir)
def add_debug_link_into_binary(binary_path, target_cpu, debug_dir):
Reported by Pylint.
Line: 12
Column: 1
def add_debug_link_into_binaries(directory, target_cpu, debug_dir):
for binary in LINUX_BINARIES:
binary_path = os.path.join(directory, binary)
if os.path.isfile(binary_path):
add_debug_link_into_binary(binary_path, target_cpu, debug_dir)
def add_debug_link_into_binary(binary_path, target_cpu, debug_dir):
if PLATFORM == 'linux' and (target_cpu == 'x86' or target_cpu == 'arm' or
Reported by Pylint.
Line: 13
Column: 1
def add_debug_link_into_binaries(directory, target_cpu, debug_dir):
for binary in LINUX_BINARIES:
binary_path = os.path.join(directory, binary)
if os.path.isfile(binary_path):
add_debug_link_into_binary(binary_path, target_cpu, debug_dir)
def add_debug_link_into_binary(binary_path, target_cpu, debug_dir):
if PLATFORM == 'linux' and (target_cpu == 'x86' or target_cpu == 'arm' or
target_cpu == 'arm64'):
Reported by Pylint.
Line: 14
Column: 1
for binary in LINUX_BINARIES:
binary_path = os.path.join(directory, binary)
if os.path.isfile(binary_path):
add_debug_link_into_binary(binary_path, target_cpu, debug_dir)
def add_debug_link_into_binary(binary_path, target_cpu, debug_dir):
if PLATFORM == 'linux' and (target_cpu == 'x86' or target_cpu == 'arm' or
target_cpu == 'arm64'):
# Skip because no objcopy binary on the given target.
Reported by Pylint.
Line: 16
Column: 1
if os.path.isfile(binary_path):
add_debug_link_into_binary(binary_path, target_cpu, debug_dir)
def add_debug_link_into_binary(binary_path, target_cpu, debug_dir):
if PLATFORM == 'linux' and (target_cpu == 'x86' or target_cpu == 'arm' or
target_cpu == 'arm64'):
# Skip because no objcopy binary on the given target.
return
Reported by Pylint.
Line: 17
Column: 31
add_debug_link_into_binary(binary_path, target_cpu, debug_dir)
def add_debug_link_into_binary(binary_path, target_cpu, debug_dir):
if PLATFORM == 'linux' and (target_cpu == 'x86' or target_cpu == 'arm' or
target_cpu == 'arm64'):
# Skip because no objcopy binary on the given target.
return
debug_name = get_debug_name(binary_path)
Reported by Pylint.
Line: 17
Column: 1
add_debug_link_into_binary(binary_path, target_cpu, debug_dir)
def add_debug_link_into_binary(binary_path, target_cpu, debug_dir):
if PLATFORM == 'linux' and (target_cpu == 'x86' or target_cpu == 'arm' or
target_cpu == 'arm64'):
# Skip because no objcopy binary on the given target.
return
debug_name = get_debug_name(binary_path)
Reported by Pylint.
build/fuses/build.py
29 issues
Line: 1
Column: 1
#!/usr/bin/env python3
from collections import OrderedDict
import json
import os
import sys
dir_path = os.path.dirname(os.path.realpath(__file__))
Reported by Pylint.
Line: 54
Column: 1
"""
with open(os.path.join(dir_path, "fuses.json5"), 'r') as f:
fuse_defaults = json.loads(''.join(line for line in f.readlines() if not line.strip()[0] == "/"), object_pairs_hook=OrderedDict)
fuse_version = fuse_defaults['_version']
del fuse_defaults['_version']
del fuse_defaults['_schema']
del fuse_defaults['_comment']
Reported by Pylint.
Line: 54
Column: 1
"""
with open(os.path.join(dir_path, "fuses.json5"), 'r') as f:
fuse_defaults = json.loads(''.join(line for line in f.readlines() if not line.strip()[0] == "/"), object_pairs_hook=OrderedDict)
fuse_version = fuse_defaults['_version']
del fuse_defaults['_version']
del fuse_defaults['_schema']
del fuse_defaults['_comment']
Reported by Pylint.
Line: 62
Column: 1
del fuse_defaults['_comment']
if fuse_version >= pow(2, 8):
raise Exception("Fuse version can not exceed one byte in size")
fuses = fuse_defaults.keys()
initial_config = ""
getters_h = ""
Reported by Pylint.
Line: 66
Column: 1
fuses = fuse_defaults.keys()
initial_config = ""
getters_h = ""
getters_cc = ""
index = len(SENTINEL) + 1
for fuse in fuses:
index += 1
Reported by Pylint.
Line: 67
Column: 1
fuses = fuse_defaults.keys()
initial_config = ""
getters_h = ""
getters_cc = ""
index = len(SENTINEL) + 1
for fuse in fuses:
index += 1
initial_config += fuse_defaults[fuse]
Reported by Pylint.
Line: 68
Column: 1
initial_config = ""
getters_h = ""
getters_cc = ""
index = len(SENTINEL) + 1
for fuse in fuses:
index += 1
initial_config += fuse_defaults[fuse]
name = ''.join(word.title() for word in fuse.split('_'))
Reported by Pylint.
Line: 69
Column: 1
initial_config = ""
getters_h = ""
getters_cc = ""
index = len(SENTINEL) + 1
for fuse in fuses:
index += 1
initial_config += fuse_defaults[fuse]
name = ''.join(word.title() for word in fuse.split('_'))
getters_h += "FUSE_EXPORT bool Is{name}Enabled();\n".replace("{name}", name)
Reported by Pylint.
Line: 71
Column: 1
getters_cc = ""
index = len(SENTINEL) + 1
for fuse in fuses:
index += 1
initial_config += fuse_defaults[fuse]
name = ''.join(word.title() for word in fuse.split('_'))
getters_h += "FUSE_EXPORT bool Is{name}Enabled();\n".replace("{name}", name)
getters_cc += """
bool Is{name}Enabled() {
Reported by Pylint.
Line: 72
Column: 1
index = len(SENTINEL) + 1
for fuse in fuses:
index += 1
initial_config += fuse_defaults[fuse]
name = ''.join(word.title() for word in fuse.split('_'))
getters_h += "FUSE_EXPORT bool Is{name}Enabled();\n".replace("{name}", name)
getters_cc += """
bool Is{name}Enabled() {
return kFuseWire[{index}] == '1';
Reported by Pylint.
build/generate_node_defines.py
29 issues
Line: 5
Column: 50
import re
import sys
DEFINE_EXTRACT_REGEX = re.compile('^ *# *define (\w*)', re.MULTILINE)
def main(outDir, headers):
defines = []
for filename in headers:
with open(filename, 'r') as f:
Reported by Pylint.
Line: 1
Column: 1
import os
import re
import sys
DEFINE_EXTRACT_REGEX = re.compile('^ *# *define (\w*)', re.MULTILINE)
def main(outDir, headers):
defines = []
for filename in headers:
Reported by Pylint.
Line: 7
Column: 1
DEFINE_EXTRACT_REGEX = re.compile('^ *# *define (\w*)', re.MULTILINE)
def main(outDir, headers):
defines = []
for filename in headers:
with open(filename, 'r') as f:
content = f.read()
defines += read_defines(content)
Reported by Pylint.
Line: 7
Column: 1
DEFINE_EXTRACT_REGEX = re.compile('^ *# *define (\w*)', re.MULTILINE)
def main(outDir, headers):
defines = []
for filename in headers:
with open(filename, 'r') as f:
content = f.read()
defines += read_defines(content)
Reported by Pylint.
Line: 8
Column: 1
DEFINE_EXTRACT_REGEX = re.compile('^ *# *define (\w*)', re.MULTILINE)
def main(outDir, headers):
defines = []
for filename in headers:
with open(filename, 'r') as f:
content = f.read()
defines += read_defines(content)
Reported by Pylint.
Line: 9
Column: 1
def main(outDir, headers):
defines = []
for filename in headers:
with open(filename, 'r') as f:
content = f.read()
defines += read_defines(content)
push_and_undef = ''
Reported by Pylint.
Line: 10
Column: 33
def main(outDir, headers):
defines = []
for filename in headers:
with open(filename, 'r') as f:
content = f.read()
defines += read_defines(content)
push_and_undef = ''
for define in defines:
Reported by Pylint.
Line: 10
Column: 1
def main(outDir, headers):
defines = []
for filename in headers:
with open(filename, 'r') as f:
content = f.read()
defines += read_defines(content)
push_and_undef = ''
for define in defines:
Reported by Pylint.
Line: 11
Column: 1
defines = []
for filename in headers:
with open(filename, 'r') as f:
content = f.read()
defines += read_defines(content)
push_and_undef = ''
for define in defines:
push_and_undef += '#pragma push_macro("%s")\n' % define
Reported by Pylint.
Line: 12
Column: 1
for filename in headers:
with open(filename, 'r') as f:
content = f.read()
defines += read_defines(content)
push_and_undef = ''
for define in defines:
push_and_undef += '#pragma push_macro("%s")\n' % define
push_and_undef += '#undef %s\n' % define
Reported by Pylint.
script/zip_manifests/check-zip-manifest.py
28 issues
Line: 27
Column: 12
return 0
if __name__ == '__main__':
sys.exit(main(*sys.argv[1:]))
Reported by Pylint.
Line: 27
Column: 12
return 0
if __name__ == '__main__':
sys.exit(main(*sys.argv[1:]))
Reported by Pylint.
Line: 1
Column: 1
#!/usr/bin/env python
import zipfile
import sys
def main(zip_path, manifest_in):
with open(manifest_in, 'r') as manifest, \
zipfile.ZipFile(zip_path, 'r', allowZip64=True) as z:
files_in_zip = set(z.namelist())
Reported by Pylint.
Line: 1
Column: 1
#!/usr/bin/env python
import zipfile
import sys
def main(zip_path, manifest_in):
with open(manifest_in, 'r') as manifest, \
zipfile.ZipFile(zip_path, 'r', allowZip64=True) as z:
files_in_zip = set(z.namelist())
Reported by Pylint.
Line: 6
Column: 1
import zipfile
import sys
def main(zip_path, manifest_in):
with open(manifest_in, 'r') as manifest, \
zipfile.ZipFile(zip_path, 'r', allowZip64=True) as z:
files_in_zip = set(z.namelist())
files_in_manifest = set([l.strip() for l in manifest.readlines()])
added_files = files_in_zip - files_in_manifest
Reported by Pylint.
Line: 7
Column: 1
import sys
def main(zip_path, manifest_in):
with open(manifest_in, 'r') as manifest, \
zipfile.ZipFile(zip_path, 'r', allowZip64=True) as z:
files_in_zip = set(z.namelist())
files_in_manifest = set([l.strip() for l in manifest.readlines()])
added_files = files_in_zip - files_in_manifest
removed_files = files_in_manifest - files_in_zip
Reported by Pylint.
Line: 8
Column: 58
def main(zip_path, manifest_in):
with open(manifest_in, 'r') as manifest, \
zipfile.ZipFile(zip_path, 'r', allowZip64=True) as z:
files_in_zip = set(z.namelist())
files_in_manifest = set([l.strip() for l in manifest.readlines()])
added_files = files_in_zip - files_in_manifest
removed_files = files_in_manifest - files_in_zip
if added_files:
Reported by Pylint.
Line: 9
Column: 1
def main(zip_path, manifest_in):
with open(manifest_in, 'r') as manifest, \
zipfile.ZipFile(zip_path, 'r', allowZip64=True) as z:
files_in_zip = set(z.namelist())
files_in_manifest = set([l.strip() for l in manifest.readlines()])
added_files = files_in_zip - files_in_manifest
removed_files = files_in_manifest - files_in_zip
if added_files:
print("Files added to bundle:")
Reported by Pylint.
Line: 10
Column: 25
with open(manifest_in, 'r') as manifest, \
zipfile.ZipFile(zip_path, 'r', allowZip64=True) as z:
files_in_zip = set(z.namelist())
files_in_manifest = set([l.strip() for l in manifest.readlines()])
added_files = files_in_zip - files_in_manifest
removed_files = files_in_manifest - files_in_zip
if added_files:
print("Files added to bundle:")
for f in sorted(list(added_files)):
Reported by Pylint.
Line: 10
Column: 1
with open(manifest_in, 'r') as manifest, \
zipfile.ZipFile(zip_path, 'r', allowZip64=True) as z:
files_in_zip = set(z.namelist())
files_in_manifest = set([l.strip() for l in manifest.readlines()])
added_files = files_in_zip - files_in_manifest
removed_files = files_in_manifest - files_in_zip
if added_files:
print("Files added to bundle:")
for f in sorted(list(added_files)):
Reported by Pylint.
build/profile_toolchain.py
26 issues
Line: 10
Column: 1
sys.path.append("%s/../../build" % os.path.dirname(os.path.realpath(__file__)))
import find_depot_tools
from vs_toolchain import \
SetEnvironmentAndGetRuntimeDllDirs, \
SetEnvironmentAndGetSDKDir, \
NormalizePath
Reported by Pylint.
Line: 11
Column: 1
sys.path.append("%s/../../build" % os.path.dirname(os.path.realpath(__file__)))
import find_depot_tools
from vs_toolchain import \
SetEnvironmentAndGetRuntimeDllDirs, \
SetEnvironmentAndGetSDKDir, \
NormalizePath
sys.path.append("%s/win_toolchain" % find_depot_tools.add_depot_tools_to_path())
Reported by Pylint.
Line: 18
Column: 1
sys.path.append("%s/win_toolchain" % find_depot_tools.add_depot_tools_to_path())
from get_toolchain_if_necessary import CalculateHash
@contextlib.contextmanager
def cwd(directory):
curdir = os.getcwd()
Reported by Pylint.
Line: 36
Column: 5
return CalculateHash('.', None)
def windows_installed_software():
import win32com.client
strComputer = "."
objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator")
objSWbemServices = objWMIService.ConnectServer(strComputer, "root\cimv2")
colItems = objSWbemServices.ExecQuery("Select * from Win32_Product")
items = []
Reported by Pylint.
Line: 5
Column: 1
import contextlib
import sys
import os
import optparse
import json
sys.path.append("%s/../../build" % os.path.dirname(os.path.realpath(__file__)))
import find_depot_tools
Reported by Pylint.
Line: 39
Column: 70
import win32com.client
strComputer = "."
objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator")
objSWbemServices = objWMIService.ConnectServer(strComputer, "root\cimv2")
colItems = objSWbemServices.ExecQuery("Select * from Win32_Product")
items = []
for objItem in colItems:
item = {}
Reported by Pylint.
Line: 1
Column: 1
from __future__ import with_statement
import contextlib
import sys
import os
import optparse
import json
sys.path.append("%s/../../build" % os.path.dirname(os.path.realpath(__file__)))
Reported by Pylint.
Line: 10
Column: 1
sys.path.append("%s/../../build" % os.path.dirname(os.path.realpath(__file__)))
import find_depot_tools
from vs_toolchain import \
SetEnvironmentAndGetRuntimeDllDirs, \
SetEnvironmentAndGetSDKDir, \
NormalizePath
Reported by Pylint.
Line: 11
Column: 1
sys.path.append("%s/../../build" % os.path.dirname(os.path.realpath(__file__)))
import find_depot_tools
from vs_toolchain import \
SetEnvironmentAndGetRuntimeDllDirs, \
SetEnvironmentAndGetSDKDir, \
NormalizePath
sys.path.append("%s/win_toolchain" % find_depot_tools.add_depot_tools_to_path())
Reported by Pylint.
Line: 18
Column: 1
sys.path.append("%s/win_toolchain" % find_depot_tools.add_depot_tools_to_path())
from get_toolchain_if_necessary import CalculateHash
@contextlib.contextmanager
def cwd(directory):
curdir = os.getcwd()
Reported by Pylint.
script/verify-chromedriver.py
23 issues
Line: 1
Column: 1
#!/usr/bin/env python
from __future__ import print_function
import argparse
import os
import re
import subprocess
import sys
Reported by Pylint.
Line: 1
Column: 1
#!/usr/bin/env python
from __future__ import print_function
import argparse
import os
import re
import subprocess
import sys
Reported by Pylint.
Line: 8
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess
import argparse
import os
import re
import subprocess
import sys
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
Reported by Bandit.
Line: 14
Column: 1
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
def main():
args = parse_args()
chromedriver_name = {
'darwin': 'chromedriver',
'win32': 'chromedriver.exe',
Reported by Pylint.
Line: 15
Column: 1
def main():
args = parse_args()
chromedriver_name = {
'darwin': 'chromedriver',
'win32': 'chromedriver.exe',
'linux2': 'chromedriver'
Reported by Pylint.
Line: 17
Column: 1
def main():
args = parse_args()
chromedriver_name = {
'darwin': 'chromedriver',
'win32': 'chromedriver.exe',
'linux2': 'chromedriver'
}
Reported by Pylint.
Line: 23
Column: 1
'linux2': 'chromedriver'
}
chromedriver_path = os.path.join(
args.source_root, args.build_dir, chromedriver_name[sys.platform])
proc = subprocess.Popen([chromedriver_path],
stdout=subprocess.PIPE, universal_newlines=True)
try:
output = proc.stdout.readline()
Reported by Pylint.
Line: 25
Column: 1
chromedriver_path = os.path.join(
args.source_root, args.build_dir, chromedriver_name[sys.platform])
proc = subprocess.Popen([chromedriver_path],
stdout=subprocess.PIPE, universal_newlines=True)
try:
output = proc.stdout.readline()
except KeyboardInterrupt:
returncode = 0
Reported by Pylint.
Line: 25
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html
chromedriver_path = os.path.join(
args.source_root, args.build_dir, chromedriver_name[sys.platform])
proc = subprocess.Popen([chromedriver_path],
stdout=subprocess.PIPE, universal_newlines=True)
try:
output = proc.stdout.readline()
except KeyboardInterrupt:
returncode = 0
Reported by Bandit.
Line: 27
Column: 1
args.source_root, args.build_dir, chromedriver_name[sys.platform])
proc = subprocess.Popen([chromedriver_path],
stdout=subprocess.PIPE, universal_newlines=True)
try:
output = proc.stdout.readline()
except KeyboardInterrupt:
returncode = 0
finally:
proc.terminate()
Reported by Pylint.
script/lib/patches.py
20 issues
Line: 1
Column: 1
#!/usr/bin/env python
import codecs
import os
def read_patch(patch_dir, patch_filename):
"""Read a patch from |patch_dir/filename| and amend the commit message with
metadata about the patch file it came from."""
Reported by Pylint.
Line: 8
Column: 1
def read_patch(patch_dir, patch_filename):
"""Read a patch from |patch_dir/filename| and amend the commit message with
metadata about the patch file it came from."""
ret = []
added_filename_line = False
patch_path = os.path.join(patch_dir, patch_filename)
with codecs.open(patch_path, encoding='utf-8') as f:
Reported by Pylint.
Line: 10
Column: 1
def read_patch(patch_dir, patch_filename):
"""Read a patch from |patch_dir/filename| and amend the commit message with
metadata about the patch file it came from."""
ret = []
added_filename_line = False
patch_path = os.path.join(patch_dir, patch_filename)
with codecs.open(patch_path, encoding='utf-8') as f:
for l in f.readlines():
line_has_correct_start = l.startswith('diff -') or l.startswith('---')
Reported by Pylint.
Line: 11
Column: 1
"""Read a patch from |patch_dir/filename| and amend the commit message with
metadata about the patch file it came from."""
ret = []
added_filename_line = False
patch_path = os.path.join(patch_dir, patch_filename)
with codecs.open(patch_path, encoding='utf-8') as f:
for l in f.readlines():
line_has_correct_start = l.startswith('diff -') or l.startswith('---')
if not added_filename_line and line_has_correct_start:
Reported by Pylint.
Line: 12
Column: 1
metadata about the patch file it came from."""
ret = []
added_filename_line = False
patch_path = os.path.join(patch_dir, patch_filename)
with codecs.open(patch_path, encoding='utf-8') as f:
for l in f.readlines():
line_has_correct_start = l.startswith('diff -') or l.startswith('---')
if not added_filename_line and line_has_correct_start:
ret.append('Patch-Filename: {}\n'.format(patch_filename))
Reported by Pylint.
Line: 13
Column: 1
ret = []
added_filename_line = False
patch_path = os.path.join(patch_dir, patch_filename)
with codecs.open(patch_path, encoding='utf-8') as f:
for l in f.readlines():
line_has_correct_start = l.startswith('diff -') or l.startswith('---')
if not added_filename_line and line_has_correct_start:
ret.append('Patch-Filename: {}\n'.format(patch_filename))
added_filename_line = True
Reported by Pylint.
Line: 13
Column: 53
ret = []
added_filename_line = False
patch_path = os.path.join(patch_dir, patch_filename)
with codecs.open(patch_path, encoding='utf-8') as f:
for l in f.readlines():
line_has_correct_start = l.startswith('diff -') or l.startswith('---')
if not added_filename_line and line_has_correct_start:
ret.append('Patch-Filename: {}\n'.format(patch_filename))
added_filename_line = True
Reported by Pylint.
Line: 14
Column: 1
added_filename_line = False
patch_path = os.path.join(patch_dir, patch_filename)
with codecs.open(patch_path, encoding='utf-8') as f:
for l in f.readlines():
line_has_correct_start = l.startswith('diff -') or l.startswith('---')
if not added_filename_line and line_has_correct_start:
ret.append('Patch-Filename: {}\n'.format(patch_filename))
added_filename_line = True
ret.append(l)
Reported by Pylint.
Line: 14
Column: 9
added_filename_line = False
patch_path = os.path.join(patch_dir, patch_filename)
with codecs.open(patch_path, encoding='utf-8') as f:
for l in f.readlines():
line_has_correct_start = l.startswith('diff -') or l.startswith('---')
if not added_filename_line and line_has_correct_start:
ret.append('Patch-Filename: {}\n'.format(patch_filename))
added_filename_line = True
ret.append(l)
Reported by Pylint.
Line: 15
Column: 1
patch_path = os.path.join(patch_dir, patch_filename)
with codecs.open(patch_path, encoding='utf-8') as f:
for l in f.readlines():
line_has_correct_start = l.startswith('diff -') or l.startswith('---')
if not added_filename_line and line_has_correct_start:
ret.append('Patch-Filename: {}\n'.format(patch_filename))
added_filename_line = True
ret.append(l)
return ''.join(ret)
Reported by Pylint.
script/patches-mtime-cache.py
16 issues
Line: 138
Column: 9
json.load(f) # Make sure it's not an empty file
print("Using existing mtime cache for patches")
return 0
except:
pass
try:
with open(args.cache_file, mode="w") as f:
mtime_cache = generate_cache(json.load(args.patches_config))
Reported by Pylint.
Line: 145
Column: 16
with open(args.cache_file, mode="w") as f:
mtime_cache = generate_cache(json.load(args.patches_config))
json.dump(mtime_cache, f, indent=2)
except Exception:
print(
"ERROR: failed to generate mtime cache for patches",
file=sys.stderr,
)
traceback.print_exc(file=sys.stderr)
Reported by Pylint.
Line: 163
Column: 16
if not args.preserve_cache:
os.remove(args.cache_file)
except Exception:
print(
"ERROR: failed to apply mtime cache for patches",
file=sys.stderr,
)
traceback.print_exc(file=sys.stderr)
Reported by Pylint.
Line: 1
Column: 1
#!/usr/bin/env python
from __future__ import print_function
import argparse
import hashlib
import json
import os
import posixpath
Reported by Pylint.
Line: 1
Column: 1
#!/usr/bin/env python
from __future__ import print_function
import argparse
import hashlib
import json
import os
import posixpath
Reported by Pylint.
Line: 16
Column: 1
from lib.patches import patch_from_dir
def patched_file_paths(patches_config):
for patch_dir, repo in patches_config.items():
for line in patch_from_dir(patch_dir).split("\n"):
if line.startswith("+++"):
yield posixpath.join(repo, line[6:])
Reported by Pylint.
Line: 23
Column: 1
yield posixpath.join(repo, line[6:])
def generate_cache(patches_config):
mtime_cache = {}
for file_path in patched_file_paths(patches_config):
if file_path in mtime_cache:
# File may be patched multiple times, we don't need to
Reported by Pylint.
Line: 36
Column: 39
print("Skipping non-existent file:", file_path)
continue
with open(file_path, "rb") as f:
mtime_cache[file_path] = {
"sha256": hashlib.sha256(f.read()).hexdigest(),
"atime": os.path.getatime(file_path),
"mtime": os.path.getmtime(file_path),
}
Reported by Pylint.
Line: 46
Column: 1
return mtime_cache
def apply_mtimes(mtime_cache):
updates = []
for file_path, metadata in mtime_cache.items():
if not os.path.exists(file_path):
print("Skipping non-existent file:", file_path)
Reported by Pylint.
Line: 54
Column: 39
print("Skipping non-existent file:", file_path)
continue
with open(file_path, "rb") as f:
if hashlib.sha256(f.read()).hexdigest() == metadata["sha256"]:
updates.append(
[file_path, metadata["atime"], metadata["mtime"]]
)
Reported by Pylint.
script/export_all_patches.py
15 issues
Line: 1
Column: 1
#!/usr/bin/env python
import argparse
import json
from lib import git
def export_patches(dirs, dry_run):
Reported by Pylint.
Line: 9
Column: 1
from lib import git
def export_patches(dirs, dry_run):
for patch_dir, repo in dirs.items():
git.export_patches(repo=repo, out_dir=patch_dir, dry_run=dry_run)
def parse_args():
Reported by Pylint.
Line: 10
Column: 1
def export_patches(dirs, dry_run):
for patch_dir, repo in dirs.items():
git.export_patches(repo=repo, out_dir=patch_dir, dry_run=dry_run)
def parse_args():
parser = argparse.ArgumentParser(description='Export Electron patches')
Reported by Pylint.
Line: 11
Column: 1
def export_patches(dirs, dry_run):
for patch_dir, repo in dirs.items():
git.export_patches(repo=repo, out_dir=patch_dir, dry_run=dry_run)
def parse_args():
parser = argparse.ArgumentParser(description='Export Electron patches')
parser.add_argument('config', nargs='+',
Reported by Pylint.
Line: 14
Column: 1
git.export_patches(repo=repo, out_dir=patch_dir, dry_run=dry_run)
def parse_args():
parser = argparse.ArgumentParser(description='Export Electron patches')
parser.add_argument('config', nargs='+',
type=argparse.FileType('r'),
help='patches\' config(s) in the JSON format')
parser.add_argument("-d", "--dry-run",
Reported by Pylint.
Line: 15
Column: 1
def parse_args():
parser = argparse.ArgumentParser(description='Export Electron patches')
parser.add_argument('config', nargs='+',
type=argparse.FileType('r'),
help='patches\' config(s) in the JSON format')
parser.add_argument("-d", "--dry-run",
help="Checks whether the exported patches need to be updated.",
Reported by Pylint.
Line: 16
Column: 1
def parse_args():
parser = argparse.ArgumentParser(description='Export Electron patches')
parser.add_argument('config', nargs='+',
type=argparse.FileType('r'),
help='patches\' config(s) in the JSON format')
parser.add_argument("-d", "--dry-run",
help="Checks whether the exported patches need to be updated.",
default=False, action='store_true')
Reported by Pylint.
Line: 19
Column: 1
parser.add_argument('config', nargs='+',
type=argparse.FileType('r'),
help='patches\' config(s) in the JSON format')
parser.add_argument("-d", "--dry-run",
help="Checks whether the exported patches need to be updated.",
default=False, action='store_true')
return parser.parse_args()
Reported by Pylint.
Line: 22
Column: 1
parser.add_argument("-d", "--dry-run",
help="Checks whether the exported patches need to be updated.",
default=False, action='store_true')
return parser.parse_args()
def main():
configs = parse_args().config
dry_run = parse_args().dry_run
Reported by Pylint.
Line: 25
Column: 1
return parser.parse_args()
def main():
configs = parse_args().config
dry_run = parse_args().dry_run
for config_json in configs:
export_patches(json.load(config_json), dry_run)
Reported by Pylint.
script/apply_all_patches.py
14 issues
Line: 1
Column: 1
#!/usr/bin/env python
import argparse
import json
import os
from lib import git
from lib.patches import patch_from_dir
Reported by Pylint.
Line: 11
Column: 1
from lib.patches import patch_from_dir
def apply_patches(dirs):
threeway = os.environ.get("ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES")
for patch_dir, repo in dirs.items():
git.import_patches(repo=repo, patch_data=patch_from_dir(patch_dir),
threeway=threeway is not None,
committer_name="Electron Scripts", committer_email="scripts@electron")
Reported by Pylint.
Line: 12
Column: 1
def apply_patches(dirs):
threeway = os.environ.get("ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES")
for patch_dir, repo in dirs.items():
git.import_patches(repo=repo, patch_data=patch_from_dir(patch_dir),
threeway=threeway is not None,
committer_name="Electron Scripts", committer_email="scripts@electron")
Reported by Pylint.
Line: 13
Column: 1
def apply_patches(dirs):
threeway = os.environ.get("ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES")
for patch_dir, repo in dirs.items():
git.import_patches(repo=repo, patch_data=patch_from_dir(patch_dir),
threeway=threeway is not None,
committer_name="Electron Scripts", committer_email="scripts@electron")
Reported by Pylint.
Line: 14
Column: 1
def apply_patches(dirs):
threeway = os.environ.get("ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES")
for patch_dir, repo in dirs.items():
git.import_patches(repo=repo, patch_data=patch_from_dir(patch_dir),
threeway=threeway is not None,
committer_name="Electron Scripts", committer_email="scripts@electron")
def parse_args():
Reported by Pylint.
Line: 19
Column: 1
committer_name="Electron Scripts", committer_email="scripts@electron")
def parse_args():
parser = argparse.ArgumentParser(description='Apply Electron patches')
parser.add_argument('config', nargs='+',
type=argparse.FileType('r'),
help='patches\' config(s) in the JSON format')
return parser.parse_args()
Reported by Pylint.
Line: 20
Column: 1
def parse_args():
parser = argparse.ArgumentParser(description='Apply Electron patches')
parser.add_argument('config', nargs='+',
type=argparse.FileType('r'),
help='patches\' config(s) in the JSON format')
return parser.parse_args()
Reported by Pylint.
Line: 21
Column: 1
def parse_args():
parser = argparse.ArgumentParser(description='Apply Electron patches')
parser.add_argument('config', nargs='+',
type=argparse.FileType('r'),
help='patches\' config(s) in the JSON format')
return parser.parse_args()
Reported by Pylint.
Line: 24
Column: 1
parser.add_argument('config', nargs='+',
type=argparse.FileType('r'),
help='patches\' config(s) in the JSON format')
return parser.parse_args()
def main():
configs = parse_args().config
for config_json in configs:
Reported by Pylint.
Line: 27
Column: 1
return parser.parse_args()
def main():
configs = parse_args().config
for config_json in configs:
apply_patches(json.load(config_json))
Reported by Pylint.