Advertisement
Guest User

grok_test_input_automator.py

a guest
May 25th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. import sys
  2. import os
  3. from tkinter import Tk
  4.  
  5. PATH = os.path.dirname(os.path.abspath(__file__))+'\input.txt'
  6.  
  7. def grok_test_case_checker(filename = PATH):
  8.     """A program that searches for a file named 'input.txt' in current directory that contains Grok test inputs/outputs and outputs to clipboard code that will print how your code fared compared to the examples at the end of every run. You just need to paste the code at the bottom of your program, out of the function. ---> Let it be known: this will clear your current clipboard! <---"""
  9.  
  10.     file = open(filename, 'r')
  11.    
  12.     counter = 1
  13.     input_lines = list()
  14.     output_lines = list()
  15.    
  16.     for line in file_input.readlines():
  17.         if counter % 2:
  18.             input_lines.append(line.strip()[4:])
  19.         else:
  20.             output_lines.append(line.strip())
  21.         counter += 1
  22.  
  23.     file.close()
  24.  
  25.     r = Tk()
  26.     r.withdraw()
  27.     r.clipboard_clear()
  28.     for line_num in range(len(input_lines)):
  29.         r.clipboard_append(f'print(f"Test {line_num}: You output {{{input_lines[line_num]}}} vs {output_lines[line_num]}")\n')
  30.     r.update()
  31.     r.destroy()
  32.    
  33. grok_test_case_checker()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement