Commit 18a9e2df by finswimmer Committed by GitHub

fix: replace clikit by cleo in several places (#3634)

parent 855bc88b
from clikit.api.args import Args
from clikit.api.args import RawArgs
from clikit.api.args.format import ArgsFormat
from clikit.api.args.format import ArgsFormatBuilder
from clikit.args import DefaultArgsParser
class RunArgsParser(DefaultArgsParser):
"""
Parser that just parses command names and leave the rest
alone to be passed to the command.
"""
def parse(
self, args, fmt, lenient=False
): # type: (RawArgs, ArgsFormat, bool) -> Args
builder = ArgsFormatBuilder()
builder.set_command_names(*fmt.get_command_names())
builder.set_arguments(*fmt.get_arguments().values())
fmt = builder.format
return super(RunArgsParser, self).parse(args, fmt, True)
def _parse(
self, raw_args, fmt, lenient
): # type: (RawArgs, ArgsFormat, bool) -> None
"""
Parse everything as a single, multi-valued argument.
"""
tokens = raw_args.tokens[:]
last_arg = list(fmt.get_arguments().values())[-1]
self._arguments[last_arg.name] = []
while True:
try:
token = tokens.pop(0)
except IndexError:
break
self._arguments[last_arg.name].append(token)
......@@ -11,7 +11,7 @@ from .env_command import EnvCommand
if TYPE_CHECKING:
from clikit.api.io import IO # noqa
from cleo.io.io import IO # noqa
from poetry.core.packages import Dependency # noqa
from poetry.core.packages import Package # noqa
......
......@@ -6,7 +6,7 @@ from typing import TYPE_CHECKING
if TYPE_CHECKING:
from logging import LogRecord # noqa
from clikit.api.io import IO # noqa
from cleo.io.io import IO # noqa
class IOHandler(logging.Handler):
......@@ -21,7 +21,7 @@ class IOHandler(logging.Handler):
level = record.levelname.lower()
err = level in ("warning", "error", "exception", "critical")
if err:
self._io.error_line(msg)
self._io.write_error_line(msg)
else:
self._io.write_line(msg)
except Exception:
......
......@@ -33,7 +33,7 @@ from .operations.update import Update
if TYPE_CHECKING:
from clikit.api.io import IO # noqa
from cleo.io.io import IO # noqa
from poetry.config.config import Config # noqa
from poetry.repositories import Pool # noqa
......
......@@ -19,7 +19,7 @@ from poetry.utils.helpers import is_dir_writable
if TYPE_CHECKING:
from clikit.api.io import IO # noqa
from cleo.io.io import IO # noqa
from poetry.core.poetry import Poetry # noqa
from poetry.utils.env import Env # noqa
......
......@@ -14,9 +14,8 @@ from .uploader import Uploader
if TYPE_CHECKING:
from cleo.io import BufferedIO # noqa
from cleo.io import ConsoleIO # noqa
from clikit.io import NullIO # noqa
from cleo.io.buffered_io import BufferedIO # noqa
from cleo.io.null_io import NullIO # noqa
from ..poetry import Poetry # noqa
......@@ -30,7 +29,7 @@ class Publisher:
def __init__(
self, poetry, io
): # type: ("Poetry", Union["ConsoleIO", "BufferedIO", "NullIO"]) -> None
): # type: ("Poetry", Union["BufferedIO", "NullIO"]) -> None
self._poetry = poetry
self._package = poetry.package
self._io = io
......
......@@ -29,8 +29,7 @@ from poetry.utils.patterns import wheel_file_re
if TYPE_CHECKING:
from cleo.io import ConsoleIO # noqa
from clikit.io import NullIO # noqa
from cleo.io.null_io import NullIO # noqa
from poetry.poetry import Poetry # noqa
......@@ -54,9 +53,7 @@ class UploadError(Exception):
class Uploader:
def __init__(
self, poetry, io
): # type: ("Poetry", Union["ConsoleIO", "NullIO"]) -> None
def __init__(self, poetry, io): # type: ("Poetry", "NullIO") -> None
self._poetry = poetry
self._package = poetry.package
self._io = io
......
......@@ -7,7 +7,7 @@ from typing import Any
import pexpect
from clikit.utils.terminal import Terminal
from cleo.terminal import Terminal
from shellingham import ShellDetectionFailure
from shellingham import detect_shell
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment