Skip to content

Commit 31b3a57

Browse files
committed
Script to only list ignored mods
I should make this an argument, but I am lazy.
1 parent 9faa2e1 commit 31b3a57

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from os import chdir, listdir
2+
from re import compile, sub
3+
4+
ignored_regex = compile('ignoredVersion=\S+')
5+
6+
# Open the log file to write changes to as the script runs
7+
with open('mo2-ignored.log', 'w') as log_file:
8+
9+
log_file.write("List of mods that will no longer ignore updates;\n")
10+
11+
# Iterate through mod directories
12+
for mod_dir in listdir():
13+
14+
# Check for separators and files related to this program, and skip them
15+
if (str(mod_dir).__contains__('_separator')
16+
or str(mod_dir).__contains__('mo2-ignored.log')
17+
or str(mod_dir).__contains__('list-ignored.py')):
18+
continue
19+
20+
# Move into mod directory
21+
chdir(str(mod_dir))
22+
23+
# Read the mod's meta.ini file to memory
24+
file_data: str
25+
changed_file_data: str
26+
try:
27+
with open('meta.ini', "r") as read_file:
28+
file_data = read_file.read()
29+
changed_file_data = sub(ignored_regex, 'ignoredVersion=', file_data)
30+
except FileNotFoundError:
31+
print(f'The mod "{mod_dir}" did not have a meta.ini file')
32+
33+
# Log mod if the data changed
34+
if file_data != changed_file_data:
35+
# Log the changed mod
36+
log_file.write(f"{str(mod_dir)}\n")
37+
38+
# Move back up to main mods directory
39+
chdir('..')
40+
41+
# Print the log
42+
with open('mo2-ignored.log', 'r') as log_file:
43+
44+
print(" ")
45+
for line in log_file:
46+
47+
print(line.strip())

0 commit comments

Comments
 (0)