2024-03-05 15:40:37 +01:00
|
|
|
from ..output.output import print_msg
|
2022-11-01 14:26:28 +01:00
|
|
|
|
|
|
|
|
2022-11-10 10:22:16 +01:00
|
|
|
def format_msg_project_package_options(
|
|
|
|
msg,
|
|
|
|
project=None,
|
|
|
|
package=None,
|
|
|
|
dest_project=None,
|
|
|
|
dest_package=None,
|
|
|
|
repository=None,
|
|
|
|
dest_repository=None,
|
|
|
|
**options,
|
|
|
|
):
|
2022-11-01 14:26:28 +01:00
|
|
|
"""
|
2022-11-07 16:18:52 +01:00
|
|
|
Format msg, project, package, dest_project, dest_package and options into a meaningful message
|
2022-11-01 14:26:28 +01:00
|
|
|
that can be printed out directly or as a debug message.
|
|
|
|
"""
|
2022-11-07 16:18:52 +01:00
|
|
|
if project and not package:
|
|
|
|
msg += f" project '{project}'"
|
|
|
|
else:
|
|
|
|
msg += f" package '{project}/{package}'"
|
2022-11-01 14:26:28 +01:00
|
|
|
|
2022-11-10 10:22:16 +01:00
|
|
|
if repository:
|
|
|
|
msg += f" repository '{repository}'"
|
|
|
|
|
|
|
|
if any([dest_project, dest_package, dest_repository]):
|
|
|
|
msg += " to"
|
|
|
|
|
2022-11-07 16:18:52 +01:00
|
|
|
if dest_project and not dest_package:
|
2022-11-10 10:22:16 +01:00
|
|
|
msg += f" project '{dest_project}'"
|
2022-11-07 16:18:52 +01:00
|
|
|
elif dest_project and dest_package:
|
2022-11-10 10:22:16 +01:00
|
|
|
msg += f" package '{dest_project}/{dest_package}'"
|
|
|
|
|
|
|
|
if dest_repository:
|
|
|
|
msg += f" repository '{dest_repository}'"
|
2022-11-01 14:26:28 +01:00
|
|
|
|
|
|
|
msg_options = [key.replace("_", "-") for key, value in options.items() if value]
|
|
|
|
if msg_options:
|
|
|
|
msg_options.sort()
|
|
|
|
msg_options_str = ", ".join(msg_options)
|
|
|
|
msg += f" options: {msg_options_str}"
|
|
|
|
|
|
|
|
return msg
|