src/black_primer/cli.py
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | # coding=utf8
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- |
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | import asyncio
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | import json
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | import logging
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | import sys
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | from datetime import datetime
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | from pathlib import Path
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | from shutil import rmtree, which
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | from tempfile import gettempdir
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | from typing import Any, List, Optional, Union
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- |
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | import click
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- |
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | from black_primer import lib
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- |
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | # If our environment has uvloop installed lets use it
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | try:
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | import uvloop
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- |
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | uvloop.install()
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | except ImportError:
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | pass
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- |
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- |
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | DEFAULT_CONFIG = Path(__file__).parent / "primer.json"
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | _timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | DEFAULT_WORKDIR = Path(gettempdir()) / f"primer.{_timestamp}"
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | LOG = logging.getLogger(__name__)
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- |
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- |
0012 0005 0011 0000 0000 0000 0001 -- 02 000 000 000 000 000 000 0000.00 0000.00 0000.00 | def _handle_debug(
0012 0005 0011 0000 0000 0000 0001 -- 02 000 000 000 000 000 000 0000.00 0000.00 0000.00 | ctx: Optional[click.core.Context],
0012 0005 0011 0000 0000 0000 0001 -- 02 000 000 000 000 000 000 0000.00 0000.00 0000.00 | param: Optional[Union[click.core.Option, click.core.Parameter]],
0012 0005 0011 0000 0000 0000 0001 -- 02 000 000 000 000 000 000 0000.00 0000.00 0000.00 | debug: Union[bool, int, str],
0012 0005 0011 0000 0000 0000 0001 -- 02 000 000 000 000 000 000 0000.00 0000.00 0000.00 | ) -> Union[bool, int, str]:
0012 0005 0011 0000 0000 0000 0001 -- 02 000 000 000 000 000 000 0000.00 0000.00 0000.00 | """Turn on debugging if asked otherwise INFO default"""
0012 0005 0011 0000 0000 0000 0001 -- 02 000 000 000 000 000 000 0000.00 0000.00 0000.00 | log_level = logging.DEBUG if debug else logging.INFO
0012 0005 0011 0000 0000 0000 0001 -- 02 000 000 000 000 000 000 0000.00 0000.00 0000.00 | logging.basicConfig(
0012 0005 0011 0000 0000 0000 0001 -- 02 000 000 000 000 000 000 0000.00 0000.00 0000.00 | format="[%(asctime)s] %(levelname)s: %(message)s (%(filename)s:%(lineno)d)",
0012 0005 0011 0000 0000 0000 0001 -- 02 000 000 000 000 000 000 0000.00 0000.00 0000.00 | level=log_level,
0012 0005 0011 0000 0000 0000 0001 -- 02 000 000 000 000 000 000 0000.00 0000.00 0000.00 | )
0012 0005 0011 0000 0000 0000 0001 -- 02 000 000 000 000 000 000 0000.00 0000.00 0000.00 | return debug
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- |
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- |
0007 0003 0003 0002 0000 0002 0002 -- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | def load_projects(config_path: Path) -> List[str]:
0007 0003 0003 0002 0000 0002 0002 -- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | with open(config_path) as config:
0007 0003 0003 0002 0000 0002 0002 -- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | return sorted(json.load(config)["projects"].keys())
0007 0003 0003 0002 0000 0002 0002 -- -- --- --- --- --- --- --- ------- ------- ------- |
0007 0003 0003 0002 0000 0002 0002 -- -- --- --- --- --- --- --- ------- ------- ------- |
0007 0003 0003 0002 0000 0002 0002 -- -- --- --- --- --- --- --- ------- ------- ------- | # Unfortunately does import time file IO - but appears to be the only
0007 0003 0003 0002 0000 0002 0002 -- -- --- --- --- --- --- --- ------- ------- ------- | # way to get `black-primer --help` to show projects list
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | DEFAULT_PROJECTS = load_projects(DEFAULT_CONFIG)
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- |
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- |
0017 0007 0015 0000 0000 0002 0000 -- 03 003 004 003 006 007 009 0025.27 0056.85 0002.25 | def _projects_callback(
0017 0007 0015 0000 0000 0002 0000 -- 03 003 004 003 006 007 009 0025.27 0056.85 0002.25 | ctx: click.core.Context,
0017 0007 0015 0000 0000 0002 0000 -- 03 003 004 003 006 007 009 0025.27 0056.85 0002.25 | param: Optional[Union[click.core.Option, click.core.Parameter]],
0017 0007 0015 0000 0000 0002 0000 -- 03 003 004 003 006 007 009 0025.27 0056.85 0002.25 | projects: str,
0017 0007 0015 0000 0000 0002 0000 -- 03 003 004 003 006 007 009 0025.27 0056.85 0002.25 | ) -> List[str]:
0017 0007 0015 0000 0000 0002 0000 -- 03 003 004 003 006 007 009 0025.27 0056.85 0002.25 | requested_projects = set(projects.split(","))
0017 0007 0015 0000 0000 0002 0000 -- 03 003 004 003 006 007 009 0025.27 0056.85 0002.25 | available_projects = set(
0017 0007 0015 0000 0000 0002 0000 -- 03 003 004 003 006 007 009 0025.27 0056.85 0002.25 | DEFAULT_PROJECTS
0017 0007 0015 0000 0000 0002 0000 -- 03 003 004 003 006 007 009 0025.27 0056.85 0002.25 | if str(DEFAULT_CONFIG) == ctx.params["config"]
0017 0007 0015 0000 0000 0002 0000 -- 03 003 004 003 006 007 009 0025.27 0056.85 0002.25 | else load_projects(ctx.params["config"])
0017 0007 0015 0000 0000 0002 0000 -- 03 003 004 003 006 007 009 0025.27 0056.85 0002.25 | )
0017 0007 0015 0000 0000 0002 0000 -- 03 003 004 003 006 007 009 0025.27 0056.85 0002.25 |
0017 0007 0015 0000 0000 0002 0000 -- 03 003 004 003 006 007 009 0025.27 0056.85 0002.25 | unavailable = requested_projects - available_projects
0017 0007 0015 0000 0000 0002 0000 -- 03 003 004 003 006 007 009 0025.27 0056.85 0002.25 | if unavailable:
0017 0007 0015 0000 0000 0002 0000 -- 03 003 004 003 006 007 009 0025.27 0056.85 0002.25 | LOG.error(f"Projects not found: {unavailable}. Available: {available_projects}")
0017 0007 0015 0000 0000 0002 0000 -- 03 003 004 003 006 007 009 0025.27 0056.85 0002.25 |
0017 0007 0015 0000 0000 0002 0000 -- 03 003 004 003 006 007 009 0025.27 0056.85 0002.25 | return sorted(requested_projects & available_projects)
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- |
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- |
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | async def async_main(
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | config: str,
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | debug: bool,
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | keep: bool,
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | long_checkouts: bool,
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | no_diff: bool,
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | projects: List[str],
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | rebase: bool,
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | workdir: str,
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | workers: int,
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | ) -> int:
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | work_path = Path(workdir)
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | if not work_path.exists():
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | LOG.debug(f"Creating {work_path}")
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | work_path.mkdir()
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 |
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | if not which("black"):
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | LOG.error("Can not find 'black' executable in PATH. No point in running")
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | return -1
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 |
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | try:
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | ret_val = await lib.process_queue(
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | config,
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | work_path,
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | workers,
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | projects,
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | keep,
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | long_checkouts,
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | rebase,
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | no_diff,
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | )
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | return int(ret_val)
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 |
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | finally:
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | if not keep and work_path.exists():
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | LOG.debug(f"Removing {work_path}")
0037 0015 0034 0000 0000 0003 0000 -- 05 003 006 005 006 009 011 0034.87 0052.30 0001.50 | rmtree(work_path, onerror=lib.handle_PermissionError)
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- |
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- |
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | @click.command(context_settings={"help_option_names": ["-h", "--help"]})
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | @click.option(
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | "-c",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | "--config",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | default=str(DEFAULT_CONFIG),
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | type=click.Path(exists=True),
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | show_default=True,
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | help="JSON config file path",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | # Eager - because config path is used by other callback options
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | is_eager=True,
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | )
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | @click.option(
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | "--debug",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | is_flag=True,
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | callback=_handle_debug,
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | show_default=True,
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | help="Turn on debug logging",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | )
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | @click.option(
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | "-k",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | "--keep",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | is_flag=True,
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | show_default=True,
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | help="Keep workdir + repos post run",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | )
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | @click.option(
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | "-L",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | "--long-checkouts",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | is_flag=True,
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | show_default=True,
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | help="Pull big projects to test",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | )
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | @click.option(
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | "--no-diff",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | is_flag=True,
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | show_default=True,
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | help="Disable showing source file changes in black output",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | )
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | @click.option(
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | "--projects",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | default=",".join(DEFAULT_PROJECTS),
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | callback=_projects_callback,
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | show_default=True,
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | help="Comma separated list of projects to run",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | )
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | @click.option(
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | "-R",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | "--rebase",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | is_flag=True,
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | show_default=True,
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | help="Rebase project if already checked out",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | )
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | @click.option(
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | "-w",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | "--workdir",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | default=str(DEFAULT_WORKDIR),
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | type=click.Path(exists=False),
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | show_default=True,
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | help="Directory path for repo checkouts",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | )
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | @click.option(
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | "-W",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | "--workers",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | default=2,
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | type=int,
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | show_default=True,
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | help="Number of parallel worker coroutines",
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | )
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | @click.pass_context
0078 0020 0076 0002 0000 0000 0002 -- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | def main(ctx: click.core.Context, **kwargs: Any) -> None:
0078 0020 0076 0002 0000 0000 0002 -- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | """primer - prime projects for blackening... 🏴"""
0078 0020 0076 0002 0000 0000 0002 -- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | LOG.debug(f"Starting {sys.argv[0]}")
0078 0020 0076 0002 0000 0000 0002 -- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | # TODO: Change to asyncio.run when Black >= 3.7 only
0078 0020 0076 0002 0000 0000 0002 -- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | loop = asyncio.get_event_loop()
0078 0020 0076 0002 0000 0000 0002 -- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | try:
0078 0020 0076 0002 0000 0000 0002 -- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | ctx.exit(loop.run_until_complete(async_main(**kwargs)))
0078 0020 0076 0002 0000 0000 0002 -- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | finally:
0078 0020 0076 0002 0000 0000 0002 -- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | loop.close()
0078 0020 0076 0002 0000 0000 0002 -- -- --- --- --- --- --- --- ------- ------- ------- |
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- |
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | if __name__ == "__main__": # pragma: nocover
---- ---- ---- ---- ---- ---- ---- -- -- --- --- --- --- --- --- ------- ------- ------- | main()