forked from Foohy/jazztronauts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fuck.py
52 lines (38 loc) · 1.19 KB
/
fuck.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
47
48
49
50
51
52
import fnmatch
import os
def getFiles(root, match):
matches = []
for root, dirnames, filenames in os.walk(root):
for filename in fnmatch.filter(filenames, match):
matches.append(os.path.join(root, filename))
return matches
# Source material names that have uppercases
materialfiles = getFiles("gamemodes/jazztronauts/content/materials", "*.*")
# Binary replace
replaceFiles = getFiles("gamemodes/jazztronauts/content/materials", "*.vmt")
replaceFiles += getFiles("gamemodes/jazztronauts/content/models", "*.mdl")
def replaceContents(filename, find, replace):
f = open(filename, 'rb')
contents = f.read().replace(find, replace)
f.close()
# Write result
f = open(filename, 'wb')
f.write(contents)
f.close()
for mat in materialfiles:
# Skip all-lowercase files
if mat.islower():
continue
basename = os.path.splitext(os.path.basename(mat))[0]
basenamelow = basename.lower()
if basename.islower():
# print("!!!! ", mat)
# continue
print(basename, mat)
for binfile in replaceFiles:
replaceContents(binfile, basename, basenamelow)
# convert to lower case
os.rename(mat, mat.lower())
# fuck you git
gitlower = "git mv --force " + mat + " " + mat.lower()
os.system(gitlower)