def process_condition()

in source/utils.py [0:0]


def process_condition(task, condition_type):
    """
    Reads 'precondition' or 'postcondition' from a task dictionary, 
    indents it (4 spaces), and adds extra indentation where necessary.
    Performs 'last_line_check' only for 'precondition'.
    """
    
    condition = task.get(condition_type)
    if condition:
        lines = condition.splitlines()
        
        updated_lines = []
        for line in lines:
            if line.startswith(" "):
                updated_lines.append("  " + line)
            else:
                updated_lines.append(line)
        updated_condition = "\n".join(updated_lines)
        last_line_indent = len(lines[-1]) - len(lines[-1].lstrip())

        if condition_type == 'pre_condition':
            last_line = lines[-1].strip()
            last_line_check = last_line.startswith("for") or last_line.startswith("if")
            return {
                'last_line_check': last_line_check,
                f'updated_{condition_type}': updated_condition, 
                'last_line_indent': last_line_indent 
            }
        elif condition_type == 'post_condition':
            return {
                f'updated_{condition_type}': updated_condition, 
                'last_line_indent': last_line_indent 
            }
    
    return None