Skip to content
Snippets Groups Projects
Select Git revision
  • f7d757cd5dcd66c68bb7ebb3c40f7311ed0ff95d
  • main default protected
  • develop
  • 1.2.2
  • 1.2.0
  • 1.1.3
  • 1.1.2
  • 1.1.1
  • 1.1.0
  • 1.0.1
  • 1.0.0
  • 0.0.3
  • 0.0.2
13 results

ExampleConfig.py

Blame
  • format.py 1.12 KiB
    def process_console_output(input_file, output_file, console_input_file):
        with open(input_file, 'r') as infile, open(output_file, 'w') as outfile, open(console_input_file, 'w') as con_infile:
            outfile.write("> \n")
            lines = infile.readlines()[2:-2]
            for line in lines:
                # add "> " at the beginning of every line if line does not start with "> "
                if line.startswith(">"):
                    # replace "> " with "? > \n< "
                    cleaned_line = ''
                    for char in line:
                        if char == '\b':
                            if len(cleaned_line) > 2:
                                cleaned_line = cleaned_line[:-1]
                        else:
                            cleaned_line += char
                    con_infile.write(cleaned_line[2:])
                    line = cleaned_line.replace(">", "? > \n<")
                else:
                    line = "> " + line
    
                outfile.write(line)
    
    
    if __name__ == "__main__":
        input_path = 'output.txt'
        output_path = 'io.txt'
        console_input_path = 'input.txt'
        process_console_output(input_path, output_path, console_input_path)