61ddb1aa07
* build: bump pylint to 2.17 Xref: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5062345 * fix pylint consider-using-f-string warnings pt 1: use flynt for automated fixes * fix pylint consider-using-f-string warnings pt 2: manual fixes * fix pylint consider-using-with warnings * fix pylint line-too-long warnings * fix pylint unspecified-encoding warnings * fix py lint consider-using-generator warning * fixup! fix pylint unspecified-encoding warnings * fix pylint line-too-long warnings
48 lines
1.1 KiB
Python
48 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
import json
|
|
import os
|
|
import warnings
|
|
|
|
from lib import git
|
|
|
|
|
|
def export_patches(target, dry_run):
|
|
repo = target.get('repo')
|
|
if not os.path.exists(repo):
|
|
warnings.warn(f'repo not found: {repo}')
|
|
return
|
|
git.export_patches(
|
|
dry_run=dry_run,
|
|
grep=target.get('grep'),
|
|
out_dir=target.get('patch_dir'),
|
|
repo=repo
|
|
)
|
|
|
|
|
|
def export_config(config, dry_run):
|
|
for target in config:
|
|
export_patches(target, 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",
|
|
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
|
|
for config_json in configs:
|
|
export_config(json.load(config_json), dry_run)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|