diff --git a/tools/audit-gradle.py b/tools/audit-gradle.py index 01c49a52b0..1648c20822 100755 --- a/tools/audit-gradle.py +++ b/tools/audit-gradle.py @@ -6,7 +6,9 @@ import sys # find all repositories that use plain HTTP urls (e.g. not HTTPS) url_pattern = re.compile( - r'repositories\s*{[^}]*http://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|%[0-9a-fA-F][0-9a-fA-F])+[^}]*}', re.DOTALL) + r'repositories\s*{[^}]*http://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|%[0-9a-fA-F][0-9a-fA-F])+[^}]*}', + re.DOTALL, +) exit_value = 0 for appid in sys.argv: @@ -20,11 +22,15 @@ for appid in sys.argv: with open(path) as fp: data = fp.read() for url in url_pattern.findall(data): - print('Found plain HTTP URL for gradle repository:\n%s\n%s' - % (path, url)) + print( + 'Found plain HTTP URL for gradle repository:\n%s\n%s' + % (path, url) + ) exit_value += 1 if exit_value: print('gradle build uses plain HTTP URLs for repositories! This is insecure!') - print('https://max.computer/blog/how-to-take-over-the-computer-of-any-java-or-clojure-or-scala-developer/') + print( + 'https://max.computer/blog/how-to-take-over-the-computer-of-any-java-or-clojure-or-scala-developer/' + ) sys.exit(exit_value) diff --git a/tools/check-git-repo-availability.py b/tools/check-git-repo-availability.py index fa42055c56..4cd91dd765 100755 --- a/tools/check-git-repo-availability.py +++ b/tools/check-git-repo-availability.py @@ -48,13 +48,18 @@ for f in files: # from class vcs_git() in fdroidserver/common.py git_config = [ - '-c', 'core.askpass=/bin/true', - '-c', 'core.sshCommand=/bin/false', - '-c', 'url.https://.insteadOf=ssh://', + '-c', + 'core.askpass=/bin/true', + '-c', + 'core.sshCommand=/bin/false', + '-c', + 'url.https://.insteadOf=ssh://', ] for domain in ('bitbucket.org', 'github.com', 'gitlab.com'): git_config.append('-c') - git_config.append('url.https://u:p@' + domain + '/.insteadOf=git@' + domain + ':') + git_config.append( + 'url.https://u:p@' + domain + '/.insteadOf=git@' + domain + ':' + ) git_config.append('-c') git_config.append('url.https://u:p@' + domain + '.insteadOf=git://' + domain) git_config.append('-c') @@ -66,10 +71,16 @@ for f in files: 'GIT_SSH': '/bin/false', # for git < 2.3 } - p = subprocess.run(['git', ] + git_config + ['ls-remote', '--exit-code', '-h', url], - env=env, - stdout=subprocess.DEVNULL, - stderr=subprocess.PIPE) + p = subprocess.run( + [ + 'git', + ] + + git_config + + ['ls-remote', '--exit-code', '-h', url], + env=env, + stdout=subprocess.DEVNULL, + stderr=subprocess.PIPE, + ) if p.returncode != 0: with open(f) as fp: raw = fp.read() diff --git a/tools/check-keyalias-collision.py b/tools/check-keyalias-collision.py index fb36c464b4..34fc1780d5 100755 --- a/tools/check-keyalias-collision.py +++ b/tools/check-keyalias-collision.py @@ -14,9 +14,11 @@ def generate_keyalias(s): base = os.path.realpath( - os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..')) -metadata_files = sorted(glob.glob(base + '/metadata/*.txt') - + glob.glob(base + '/metadata/*.yml')) + os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..') +) +metadata_files = sorted( + glob.glob(base + '/metadata/*.txt') + glob.glob(base + '/metadata/*.yml') +) if not metadata_files: print('No metadata files found!') diff --git a/tools/find-changed-builds.py b/tools/find-changed-builds.py index 42947a66b7..7558a2e3ff 100755 --- a/tools/find-changed-builds.py +++ b/tools/find-changed-builds.py @@ -14,7 +14,7 @@ for appid in sorted(changed): metadata_file = 'metadata/%s.yml' % appid diff = subprocess.check_output( ( - 'git diff --no-color --diff-filter=d FETCH_HEAD...HEAD -- ' + metadata_file + 'git diff --no-color --diff-filter=d FETCH_HEAD...HEAD -- ' + metadata_file ).split(' ') ) @@ -71,7 +71,8 @@ for appid in sorted(changed): signatures_dir = 'metadata/%s/signatures/' % appid diff = subprocess.check_output( ( - 'git diff --name-only --no-color --diff-filter=d FETCH_HEAD...HEAD -- ' + signatures_dir + 'git diff --name-only --no-color --diff-filter=d FETCH_HEAD...HEAD -- ' + + signatures_dir ).split(' ') ) for f in diff.split(): diff --git a/tools/make-summary-translatable.py b/tools/make-summary-translatable.py index 157a2a3d8e..4a74451fa5 100755 --- a/tools/make-summary-translatable.py +++ b/tools/make-summary-translatable.py @@ -13,8 +13,11 @@ for f in glob.glob('metadata/*.yml'): raw = fp.read() data = yaml.load(raw) archive_policy = data.get('ArchivePolicy') - if 'Disabled' not in data and 'Summary' in data \ - and (archive_policy is None or not archive_policy.startswith('0 ')): + if ( + 'Disabled' not in data + and 'Summary' in data + and (archive_policy is None or not archive_policy.startswith('0 ')) + ): en_US_dir = f[:-4] + '/en-US/' os.makedirs(en_US_dir, exist_ok=True) with open(en_US_dir + '/summary.txt', 'w') as fp: @@ -22,8 +25,9 @@ for f in glob.glob('metadata/*.yml'): with open(f, 'w') as out: out.write(re.sub(r'Summary:[^\n]+\n', r'', raw)) packageName = f[9:-4] - scraped_glob = os.path.join('/path/to/scraper/metadata/', - packageName, '[a-z]*', 'short_description.txt') + scraped_glob = os.path.join( + '/path/to/scraper/metadata/', packageName, '[a-z]*', 'short_description.txt' + ) for df in glob.glob(scraped_glob): locale = os.path.basename(os.path.dirname(df)) with open(df) as fp: diff --git a/tools/rewrite-git-redirects.py b/tools/rewrite-git-redirects.py index d40552c994..f79241f0c5 100755 --- a/tools/rewrite-git-redirects.py +++ b/tools/rewrite-git-redirects.py @@ -25,7 +25,11 @@ for f in files: repo_url = None if 'Repo' in data: repo_url = data['Repo'].strip().rstrip('/') - if repo_url and not repo_url.endswith('.git') and repo_url.startswith('https://gitlab'): + if ( + repo_url + and not repo_url.endswith('.git') + and repo_url.startswith('https://gitlab') + ): new_url = repo_url + '.git' print("Repo:", data['Repo'], "\n --> " + new_url + "'") with open(f) as fp: diff --git a/tools/schedule-issuebot.py b/tools/schedule-issuebot.py index 34503bc5a2..627cce879c 100755 --- a/tools/schedule-issuebot.py +++ b/tools/schedule-issuebot.py @@ -27,7 +27,9 @@ for mr in project.mergerequests.list(state='opened', order_by='updated_at'): if m: commit_ids.append(m.group(1)) if not commit_ids and found_issuebot_post: - print(mr.iid, 'issuebot has posted without trigger commit ID, not running again') + print( + mr.iid, 'issuebot has posted without trigger commit ID, not running again' + ) elif mr.sha in commit_ids: print(mr.iid, 'issuebot has run on %s, not running again' % mr.sha) else: