Commit 7a372c75 by Sébastien Eustace

Make terminal colors more consistent

parent 7a34f6ea
......@@ -21,7 +21,7 @@ class BuildCommand(EnvCommand):
package = self.poetry.package
self.line(
"Building <info>{}</> (<comment>{}</>)".format(
"Building <c1>{}</c1> (<b>{}</b>)".format(
package.pretty_name, package.version
)
)
......
......@@ -116,11 +116,7 @@ class DebugResolveCommand(InitCommand):
current_python_version
) or not env.is_valid_for_marker(pkg.marker):
continue
row = [
"<info>{}</info>".format(pkg.name),
"<b>{}</b>".format(pkg.version),
"",
]
row = ["<c1>{}</c1>".format(pkg.name), "<b>{}</b>".format(pkg.version), ""]
if not pkg.marker.is_any():
row[2] = str(pkg.marker)
......
......@@ -52,7 +52,7 @@ class InitCommand(Command):
]
help = """\
The <info>init</info> command creates a basic <comment>pyproject.toml</> file in the current directory.
The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the current directory.
"""
def __init__(self):
......@@ -249,7 +249,7 @@ The <info>init</info> command creates a basic <comment>pyproject.toml</> file in
choices.append(found_package.pretty_name)
self.line(
"Found <info>{}</info> packages matching <info>{}</info>".format(
"Found <info>{}</info> packages matching <c1>{}</c1>".format(
len(matches), package
)
)
......@@ -277,7 +277,7 @@ The <info>init</info> command creates a basic <comment>pyproject.toml</> file in
)
self.line(
"Using version <info>{}</info> for <info>{}</info>".format(
"Using version <b>{}</b> for <c1>{}</c1>".format(
package_constraint, package
)
)
......
......@@ -77,7 +77,7 @@ exist it will look for <comment>pyproject.toml</> and do the same.
return 0
self.line(
" - Installing <info>{}</info> (<comment>{}</comment>)".format(
" - Installing <c1>{}</c1> (<b>{}</b>)".format(
self.poetry.package.pretty_name, self.poetry.package.pretty_version
)
)
......
......@@ -80,8 +80,8 @@ lists all packages available."""
return 0
rows = [
["<info>name</>", " : <info>{}</>".format(pkg.pretty_name)],
["<info>version</>", " : <comment>{}</>".format(pkg.pretty_version)],
["<info>name</>", " : <c1>{}</>".format(pkg.pretty_name)],
["<info>version</>", " : <b>{}</b>".format(pkg.pretty_version)],
["<info>description</>", " : {}".format(pkg.description)],
]
......@@ -93,7 +93,7 @@ lists all packages available."""
self.line("<info>dependencies</info>")
for dependency in pkg.requires:
self.line(
" - {} <comment>{}</>".format(
" - <c1>{}</c1> <b>{}</b>".format(
dependency.pretty_name, dependency.pretty_constraint
)
)
......@@ -211,7 +211,7 @@ lists all packages available."""
self.line(line)
def display_package_tree(self, io, package, installed_repo):
io.write("<info>{}</info>".format(package.pretty_name))
io.write("<c1>{}</c1>".format(package.pretty_name))
description = ""
if package.description:
description = " " + package.description
......
......@@ -47,7 +47,7 @@ patch, minor, major, prepatch, preminor, premajor, prerelease.
)
self.line(
"Bumping version from <comment>{}</> to <info>{}</>".format(
"Bumping version from <b>{}</> to <fg=green>{}</>".format(
self.poetry.package.pretty_version, version
)
)
......
......@@ -16,7 +16,7 @@ class ApplicationConfig(BaseApplicationConfig):
super(ApplicationConfig, self).configure()
self.add_style(Style("c1").fg("cyan"))
self.add_style(Style("info").fg("cyan"))
self.add_style(Style("info").fg("blue"))
self.add_style(Style("comment").fg("green"))
self.add_style(Style("error").fg("red").bold())
self.add_style(Style("warning").fg("yellow"))
......
......@@ -305,7 +305,7 @@ class Installer:
if operation.skipped:
if self.is_verbose() and (self._execute_operations or self.is_dry_run()):
self._io.write_line(
" - Skipping <info>{}</> (<comment>{}</>) {}".format(
" - Skipping <c1>{}</c1> (<b>{}</b>) {}".format(
operation.package.pretty_name,
operation.package.full_pretty_version,
operation.skip_reason,
......@@ -316,7 +316,7 @@ class Installer:
if self._execute_operations or self.is_dry_run():
self._io.write_line(
" - Installing <info>{}</> (<comment>{}</>)".format(
" - Installing <c1>{}</c1> (<b>{}</b>)".format(
operation.package.pretty_name, operation.package.full_pretty_version
)
)
......@@ -333,7 +333,7 @@ class Installer:
if operation.skipped:
if self.is_verbose() and (self._execute_operations or self.is_dry_run()):
self._io.write_line(
" - Skipping <info>{}</> (<comment>{}</>) {}".format(
" - Skipping <c1>{}</c1> (<comment>{}</>) {}".format(
target.pretty_name,
target.full_pretty_version,
operation.skip_reason,
......@@ -360,7 +360,7 @@ class Installer:
if operation.skipped:
if self.is_verbose() and (self._execute_operations or self.is_dry_run()):
self._io.write_line(
" - Not removing <info>{}</> (<comment>{}</>) {}".format(
" - Not removing <c1>{}</c1> (<b>{}</b>) {}".format(
operation.package.pretty_name,
operation.package.full_pretty_version,
operation.skip_reason,
......@@ -371,7 +371,7 @@ class Installer:
if self._execute_operations or self.is_dry_run():
self._io.write_line(
" - Removing <info>{}</> (<comment>{}</>)".format(
" - Removing <c1>{}</c1> (<b>{}</b>)".format(
operation.package.pretty_name, operation.package.full_pretty_version
)
)
......
......@@ -26,8 +26,8 @@ class Publisher:
def publish(self, repository_name, username, password, cert=None, client_cert=None):
if repository_name:
self._io.write_line(
"Publishing <info>{}</info> (<comment>{}</comment>) "
"to <fg=cyan>{}</>".format(
"Publishing <c1>{}</c1> (<b>{}</b>) "
"to <info>{}</info>".format(
self._package.pretty_name,
self._package.pretty_version,
repository_name,
......@@ -35,8 +35,8 @@ class Publisher:
)
else:
self._io.write_line(
"Publishing <info>{}</info> (<comment>{}</comment>) "
"to <fg=cyan>PyPI</>".format(
"Publishing <c1>{}</c1> (<b>{}</b>) "
"to <info>PyPI</info>".format(
self._package.pretty_name, self._package.pretty_version
)
)
......
......@@ -229,7 +229,7 @@ class Uploader:
encoder = MultipartEncoder(data_to_send)
bar = self._io.progress_bar(encoder.len)
bar.set_format(
" - Uploading <info>{0}</> <comment>%percent%%</>".format(file.name)
" - Uploading <c1>{0}</c1> <b>%percent%%</b>".format(file.name)
)
monitor = MultipartEncoderMonitor(
encoder, lambda monitor: bar.set_progress(monitor.bytes_read)
......@@ -245,13 +245,18 @@ class Uploader:
)
if resp.ok:
bar.set_format(
" - Uploading <c1>{0}</c1> <fg=green>%percent%%</>".format(
file.name
)
)
bar.finish()
self._io.write_line("")
else:
if self._io.output.supports_ansi():
self._io.overwrite(
" - Uploading <info>{0}</> <error>{1}%</>".format(
" - Uploading <c1>{0}</c1> <error>{1}%</>".format(
file.name, int(math.floor(bar._percent * 100))
)
)
......
......@@ -708,44 +708,42 @@ class Provider:
m2 = re.match(r"(.+?) \((.+?)\)", m.group(1))
if m2:
name = m2.group(1)
version = " (<comment>{}</comment>)".format(m2.group(2))
version = " (<b>{}</b>)".format(m2.group(2))
else:
name = m.group(1)
version = ""
message = (
"<fg=blue>fact</>: <info>{}</info>{} "
"depends on <info>{}</info> (<comment>{}</comment>)".format(
"<fg=blue>fact</>: <c1>{}</c1>{} "
"depends on <c1>{}</c1> (<b>{}</b>)".format(
name, version, m.group(2), m.group(3)
)
)
elif " is " in message:
message = re.sub(
"fact: (.+) is (.+)",
"<fg=blue>fact</>: <info>\\1</info> is <comment>\\2</comment>",
"<fg=blue>fact</>: <c1>\\1</c1> is <b>\\2</b>",
message,
)
else:
message = re.sub(
r"(?<=: )(.+?) \((.+?)\)",
"<info>\\1</info> (<comment>\\2</comment>)",
message,
r"(?<=: )(.+?) \((.+?)\)", "<c1>\\1</c1> (<b>\\2</b>)", message
)
message = "<fg=blue>fact</>: {}".format(message.split("fact: ")[1])
elif message.startswith("selecting "):
message = re.sub(
r"selecting (.+?) \((.+?)\)",
"<fg=blue>selecting</> <info>\\1</info> (<comment>\\2</comment>)",
"<fg=blue>selecting</> <c1>\\1</c1> (<b>\\2</b>)",
message,
)
elif message.startswith("derived:"):
m = re.match(r"derived: (.+?) \((.+?)\)$", message)
if m:
message = "<fg=blue>derived</>: <info>{}</info> (<comment>{}</comment>)".format(
message = "<fg=blue>derived</>: <c1>{}</c1> (<b>{}</b>)".format(
m.group(1), m.group(2)
)
else:
message = "<fg=blue>derived</>: <info>{}</info>".format(
message = "<fg=blue>derived</>: <c1>{}</c1>".format(
message.split("derived: ")[1]
)
elif message.startswith("conflict:"):
......@@ -754,14 +752,14 @@ class Provider:
m2 = re.match(r"(.+?) \((.+?)\)", m.group(1))
if m2:
name = m2.group(1)
version = " (<comment>{}</comment>)".format(m2.group(2))
version = " (<b>{}</b>)".format(m2.group(2))
else:
name = m.group(1)
version = ""
message = (
"<fg=red;options=bold>conflict</>: <info>{}</info>{} "
"depends on <info>{}</info> (<comment>{}</comment>)".format(
"<fg=red;options=bold>conflict</>: <c1>{}</c1>{} "
"depends on <c1>{}</c1> (<b>{}</b>)".format(
name, version, m.group(2), m.group(3)
)
)
......
......@@ -545,9 +545,7 @@ class EnvManager(object):
continue
if supported_python.allows(Version.parse(python_patch)):
io.write_line(
"Using <info>{}</info> ({})".format(python, python_patch)
)
io.write_line("Using <c1>{}</c1> ({})".format(python, python_patch))
executable = python
python_minor = ".".join(python_patch.split(".")[:2])
break
......@@ -576,19 +574,19 @@ class EnvManager(object):
return SystemEnv(Path(sys.prefix))
io.write_line(
"Creating virtualenv <info>{}</> in {}".format(name, str(venv_path))
"Creating virtualenv <c1>{}</> in {}".format(name, str(venv_path))
)
self.build_venv(str(venv), executable=executable)
else:
if force:
io.write_line(
"Recreating virtualenv <info>{}</> in {}".format(name, str(venv))
"Recreating virtualenv <c1>{}</> in {}".format(name, str(venv))
)
self.remove_venv(str(venv))
self.build_venv(str(venv), executable=executable)
elif io.is_very_verbose():
io.write_line("Virtualenv <info>{}</> already exists.".format(name))
io.write_line("Virtualenv <c1>{}</> already exists.".format(name))
# venv detection:
# stdlib venv may symlink sys.executable, so we can't use realpath.
......
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