# Path: rebasehelper/constants.py
# ENCODING: str = locale.getpreferredencoding()
# 
# Path: rebasehelper/logger.py
# class CustomLogger(logging.Logger):
# 
#     TRACE: int = logging.DEBUG + 1
#     VERBOSE: int = logging.DEBUG + 2
#     SUCCESS: int = logging.INFO + 5
#     HEADING: int = logging.INFO + 6
#     IMPORTANT: int = logging.INFO + 7
# 
#     _nameToLevel: Dict[str, int] = {
#         'TRACE': TRACE,
#         'VERBOSE': VERBOSE,
#         'SUCCESS': SUCCESS,
#         'HEADING': HEADING,
#         'IMPORTANT': IMPORTANT,
#     }
# 
#     def __init__(self, name, level=logging.NOTSET):
#         super().__init__(name, level)
# 
#         for lev, severity in self._nameToLevel.items():
#             logging.addLevelName(severity, lev)
# 
#     def __getattr__(self, level):
#         severity = self._nameToLevel.get(level.upper())
# 
#         def log(message, *args, **kwargs):
#             if self.isEnabledFor(severity):
#                 self._log(severity, message, args, **kwargs)
# 
#         if severity:
#             return log
# 
#         raise AttributeError


import logging
import os
import subprocess
import tempfile
from typing import cast
from rebasehelper.constants import ENCODING
from rebasehelper.logger import CustomLogger

        Args:
            cmd (iterable): A sequence of program arguments.
            cwd (str): Working directory for the command.
            env (dict): Environment variables for the new process.
            input_file (str, typing.BytesIO): File to read the input from.
            output_file (str, typing.BytesIO): File to write the output of the command to.
            ignore_stderr (bool): Whether to ignore stderr output.
            shell (bool): Whether to run the command in a shell.

        Returns:
            int: Exit code of the subprocess.

        """
        close_out_file = False
        close_in_file = False

        logger.debug("cmd=%s, cwd=%s, env=%s, input_file=%s, output_file=%s, shell=%s",
                     str(cmd), str(cwd), str(env), str(input_file), str(output_file), str(shell))

        # write the output to a file/file-like object?
        try:
            out_file = open(output_file, 'wb')
        except TypeError:
            out_file = output_file
        else:
            close_out_file = True

        # read the input from a file/file-like object?
        try:

# Path: rebasehelper/constants.py
# ENCODING: str = locale.getpreferredencoding()
# 
# Path: rebasehelper/logger.py
# class CustomLogger(logging.Logger):
# 
#     TRACE: int = logging.DEBUG + 1
#     VERBOSE: int = logging.DEBUG + 2
#     SUCCESS: int = logging.INFO + 5
#     HEADING: int = logging.INFO + 6
#     IMPORTANT: int = logging.INFO + 7
# 
#     _nameToLevel: Dict[str, int] = {
#         'TRACE': TRACE,
#         'VERBOSE': VERBOSE,
#         'SUCCESS': SUCCESS,
#         'HEADING': HEADING,
#         'IMPORTANT': IMPORTANT,
#     }
# 
#     def __init__(self, name, level=logging.NOTSET):
#         super().__init__(name, level)
# 
#         for lev, severity in self._nameToLevel.items():
#             logging.addLevelName(severity, lev)
# 
#     def __getattr__(self, level):
#         severity = self._nameToLevel.get(level.upper())
# 
#         def log(message, *args, **kwargs):
#             if self.isEnabledFor(severity):
#                 self._log(severity, message, args, **kwargs)
# 
#         if severity:
#             return log
# 
#         raise AttributeError


# Path: rebasehelper/helpers/process_helper.py
import logging
import os
import subprocess
import tempfile
from typing import cast
from rebasehelper.constants import ENCODING
from rebasehelper.logger import CustomLogger


        Args:
            cmd (iterable): A sequence of program arguments.
            cwd (str): Working directory for the command.
            env (dict): Environment variables for the new process.
            input_file (str, typing.BytesIO): File to read the input from.
            output_file (str, typing.BytesIO): File to write the output of the command to.
            ignore_stderr (bool): Whether to ignore stderr output.
            shell (bool): Whether to run the command in a shell.

        Returns:
            int: Exit code of the subprocess.

        """
        close_out_file = False
        close_in_file = False

        logger.debug("cmd=%s, cwd=%s, env=%s, input_file=%s, output_file=%s, shell=%s",
                     str(cmd), str(cwd), str(env), str(input_file), str(output_file), str(shell))

        # write the output to a file/file-like object?
        try:
            out_file = open(output_file, 'wb')
        except TypeError:
            out_file = output_file
        else:
            close_out_file = True

        # read the input from a file/file-like object?
        try:

            in_file = open(input_file, 'r', encoding=ENCODING)