├── .idea ├── .gitignore ├── QueraTestCaseGenerator.iml ├── inspectionProfiles │ └── profiles_settings.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── README.md └── TestCaseGenerator.py /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /workspace.xml 3 | -------------------------------------------------------------------------------- /.idea/QueraTestCaseGenerator.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # QueraTestCaseGenerator 2 | 3 | Simple script which generates [Quera.ir](https://Quera.ir) test cases inside project folder directory by making a .zip file. 4 | 5 | This script can be used by everyone who want to write their own test cases for their questions on Quera. 6 | 7 | 8 | (Test cases are divided into 2 folders: `in` & `out` , and each folder follows { input1.txt , input2.txt , ... } || { output1.txt , output2.txt , ...} pattern ) 9 | -------------------------------------------------------------------------------- /TestCaseGenerator.py: -------------------------------------------------------------------------------- 1 | import os 2 | import zipfile 3 | 4 | def zipdir(path, ziph): 5 | # ziph is zipfile handle 6 | for root, dirs, files in os.walk(path): 7 | for file in files: 8 | ziph.write(os.path.join(root, file), os.path.relpath(os.path.join(root, file), os.path.join(path, '..'))) 9 | 10 | 11 | 12 | path = os.getcwd() 13 | 14 | print("Enter Folder Name:") 15 | folderName = input() 16 | path += "\\" + folderName + "\\"; 17 | 18 | try: 19 | os.mkdir(path) 20 | path1 = path + "\\in" 21 | path2 = path + "\\out" 22 | os.mkdir(path1) 23 | os.mkdir(path2) 24 | except OSError: 25 | print("Creation of the directory %s failed" % path) 26 | else: 27 | print("Successfully created the directory %s " % path) 28 | 29 | cnt = 1 30 | while True: 31 | print("input " + str(cnt) + ":") 32 | 33 | lines = [] 34 | while True: 35 | line = input() 36 | if line: 37 | lines.append(line) 38 | else: 39 | break 40 | inp = '\n'.join(lines) 41 | 42 | print("output " + str(cnt) + ":") 43 | 44 | lines = [] 45 | while True: 46 | line = input() 47 | if line: 48 | lines.append(line) 49 | else: 50 | break 51 | out = '\n'.join(lines) 52 | 53 | f = open(path1 + "\input" + str(cnt) + ".txt", "w") 54 | f.write(inp) 55 | f.close() 56 | 57 | f = open(path2 + "\output" + str(cnt) + ".txt", "w") 58 | f.write(out) 59 | f.close() 60 | 61 | print("done? type \"Y\" \tOtherwise, type anything:") 62 | if input() == "Y": 63 | if __name__ == '__main__': 64 | zipf = zipfile.ZipFile(folderName + '.zip', 'w', zipfile.ZIP_DEFLATED) 65 | zipdir(path+"\\in", zipf) 66 | zipdir(path+"\\out", zipf) 67 | zipf.close() 68 | break 69 | 70 | cnt += 1 71 | print("GG!") 72 | --------------------------------------------------------------------------------