This repository has been archived by the owner on Dec 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ungrader.py
46 lines (37 loc) · 1.91 KB
/
Ungrader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import os
import glob
# Sets the main directory
main_path = input("Enter your scripts path. \n Example: D:/Unity Projects/MyGreatProject/Assets/Scripts/ \n ")
# Gets a list of everything in the main directory including folders
main_directory = os.listdir(main_path)
# This list will hold all of the folders to search through, including the main folder
sub_directories = []
# Adds the main folder to to the list of folders
sub_directories.append(main_path)
# Loops through everthing in the main folder, searching for sub folders
for item in main_directory:
# Creates the full path to each item)
item_path = os.path.join(main_path, item)
# Checks each item to see if it is a directory
if os.path.isdir(item_path) == True:
# If it is a folder it is added to the list
sub_directories.append(item_path)
for directory in sub_directories:
for files in glob.glob(os.path.join(directory,"*.cs")): #Only C# files will work
f = open( files, 'r' ) #Open files in read-only mode
file_contents = f.read() #Read file
if "ref " in file_contents: #Contains ref
print("Files with ref:", f.name + "; \n") #Type file name
print("Replace 'ref ' with '' ")
if "out var " in file_contents: #Contains out var
print(" Files with out var ", f.name + "; \n") #Type file name
print("Replace 'out var ' with '' ")
if "=>" in file_contents: #Contains =>
print(" Files with => ", f.name + "; \n") #Type file name
print("Replace '=>' with '=' ")
if "contactCount" in file_contents: #Contains contactCount
print(" Files with => ", f.name + "; \n") #Type file name
print("Replace 'contactCount' with 'contacts.count' ")
answer = input("Close app? yes or no") #Ask should we close the app
if answer in ('yes', 'no'): #Yes is an only option. Accept your faith.
exit() #Closing...