# Path: catkin_tools/common.py
# def wide_log(msg, **kwargs):
#     """Prints a message to the screen, filling the remainder of the screen with spaces
# 
#     This is useful for printing lines which will completely overwrite previous
#     content printed with a carriage return at the end.
# 
#     If the message is wider than the terminal, then no filling is done.
# 
#     The wide logging can be disabled with :py:func:`disable_wide_log`, in order
#     to prevent queries to the terminal width, which is useful when output is
#     not to a terminal, like when being used with Continuous Integration.
# 
#     Truncating and right hand side messages are disabled when wide_log is
#     disabled as well.
# 
#     When a right hand side message is given, it implies truncate is True.
# 
#     :param msg: message to be printed
#     :type msg: str
#     :param rhs: message to print at the right hand side of the screen
#     :type rhs: str
#     :param truncate: If True, messages wider the then terminal will be truncated
#     :type truncate: bool
#     """
#     try:
#         global wide_log_fn
#         wide_log_fn(msg, **kwargs)
#     except IOError:
#         # This happens when someone ctrl-c's during a log message
#         pass


import argparse
import os
import re
import sys
import catkin_tools.execution.job_server as job_server
from multiprocessing import cpu_count
from catkin_tools.common import wide_log
        input_make_args,
        force_single_threaded_when_running_tests=False):
    """Special handling for make arguments.

    If force_single_threaded_when_running_tests is True, jobs flags are
    replaced with -j1, because tests cannot handle parallelization.

    If no job flags are present and there are none in the MAKEFLAGS environment
    variable, then make flags are set to the cpu_count, e.g. -j4 -l4.

    :param input_make_args: list of make arguments to be handled
    :type input_make_args: list
    :param force_single_threaded_when_running_tests: self explanatory
    :type force_single_threaded_when_running_tests: bool
    :returns: copied list of make arguments, potentially with some modifications
    :rtype: list
    """
    make_args = list(input_make_args)

    # Get the values for the jobs flags which may be in the make args
    jobs_dict = extract_jobs_flags_values(' '.join(make_args))
    jobs_args = extract_jobs_flags(' '.join(make_args))
    if jobs_args:
        # Remove jobs flags from cli args if they're present
        make_args = re.sub(' '.join(jobs_args), '', ' '.join(make_args)).split()

    if force_single_threaded_when_running_tests:
        # force single threaded execution when running test since rostest does not support multiple parallel runs
        run_tests = [a for a in make_args if a.startswith('run_tests')]
        if run_tests:

# Path: catkin_tools/common.py
# def wide_log(msg, **kwargs):
#     """Prints a message to the screen, filling the remainder of the screen with spaces
# 
#     This is useful for printing lines which will completely overwrite previous
#     content printed with a carriage return at the end.
# 
#     If the message is wider than the terminal, then no filling is done.
# 
#     The wide logging can be disabled with :py:func:`disable_wide_log`, in order
#     to prevent queries to the terminal width, which is useful when output is
#     not to a terminal, like when being used with Continuous Integration.
# 
#     Truncating and right hand side messages are disabled when wide_log is
#     disabled as well.
# 
#     When a right hand side message is given, it implies truncate is True.
# 
#     :param msg: message to be printed
#     :type msg: str
#     :param rhs: message to print at the right hand side of the screen
#     :type rhs: str
#     :param truncate: If True, messages wider the then terminal will be truncated
#     :type truncate: bool
#     """
#     try:
#         global wide_log_fn
#         wide_log_fn(msg, **kwargs)
#     except IOError:
#         # This happens when someone ctrl-c's during a log message
#         pass


# Path: catkin_tools/argument_parsing.py
import argparse
import os
import re
import sys
import catkin_tools.execution.job_server as job_server
from multiprocessing import cpu_count
from catkin_tools.common import wide_log

        input_make_args,
        force_single_threaded_when_running_tests=False):
    """Special handling for make arguments.

    If force_single_threaded_when_running_tests is True, jobs flags are
    replaced with -j1, because tests cannot handle parallelization.

    If no job flags are present and there are none in the MAKEFLAGS environment
    variable, then make flags are set to the cpu_count, e.g. -j4 -l4.

    :param input_make_args: list of make arguments to be handled
    :type input_make_args: list
    :param force_single_threaded_when_running_tests: self explanatory
    :type force_single_threaded_when_running_tests: bool
    :returns: copied list of make arguments, potentially with some modifications
    :rtype: list
    """
    make_args = list(input_make_args)

    # Get the values for the jobs flags which may be in the make args
    jobs_dict = extract_jobs_flags_values(' '.join(make_args))
    jobs_args = extract_jobs_flags(' '.join(make_args))
    if jobs_args:
        # Remove jobs flags from cli args if they're present
        make_args = re.sub(' '.join(jobs_args), '', ' '.join(make_args)).split()

    if force_single_threaded_when_running_tests:
        # force single threaded execution when running test since rostest does not support multiple parallel runs
        run_tests = [a for a in make_args if a.startswith('run_tests')]
        if run_tests:

            wide_log('Forcing "-j1" for running unit tests.')