Skip to content

Commit

Permalink
Update script to use SyndiShanX change list
Browse files Browse the repository at this point in the history
Shamelessly copied from their Update-Classes.py
  • Loading branch information
TakosThings committed Jul 14, 2024
1 parent f4ae568 commit 2988fc9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
classes_mapping.csv
Changes.txt
28 changes: 18 additions & 10 deletions scripts/update_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import csv

MODULES_PATH = "../src/modules"
CLASS_MAP = "classes_mapping.csv" # https://github.com/NyxIsBad/discordscripts/blob/master/classes_mapping.csv
CHANGES = "Changes.txt" # https://github.com/SyndiShanX/Update-Classes/blob/main/Changes.txt

# Get all SCSS files and put them in a list
filelist = []
Expand All @@ -14,20 +14,28 @@
# Find and replace operation
# For each SCSS file in the file list...
for file in filelist:
# Open the file in memory
# Open the file
print("opening: ", file)
with open(file, "r", encoding="utf-8") as file_obj:
filedata = file_obj.read()

# Open the CSV
with open(CLASS_MAP, encoding="utf-8") as f:
csv_reader = csv.DictReader(f)
next(csv_reader) # Skips the header
# Open the changes file
with open(CHANGES, 'r') as rawFile:
rawText = "\n".join(line.rstrip() for line in rawFile).split('\n')

# Find and replace old class with new class
for line in csv_reader:
# print("finding: ", line["class_old"])
filedata = filedata.replace(line["class_old"], line["class_new"])
# Start a counter
i = 0
classNum = len(rawText) - 1

# Make changes
while i < classNum:
class1 = rawText[i]
class2 = rawText[i + 1]

filedata = filedata.replace(class1, class2)

# Increment counter
i = i + 2

# Write the file out
with open(file, "w", encoding="utf-8") as file_obj:
Expand Down

0 comments on commit 2988fc9

Please sign in to comment.