-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfix_case.py
30 lines (26 loc) · 1.05 KB
/
fix_case.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
"""
The windows file system is case insensitive but git is case sensitive.
This means that if you change the capitalisation of the file git will not notice.
The only way I have found is to delete the files with wrong capitalisation, commit their removal and readd them again.
"""
import os
import glob
import zipfile
zip_path = r"C:\Users\james_000\Downloads\PyMCTranslate-dev.zip"
if os.path.isfile(zip_path) and os.path.isdir("PyMCTranslate/json"):
git = set()
with zipfile.ZipFile(zip_path) as zip:
for p in zip.namelist():
p: str
if "PyMCTranslate/json/" in p and p.endswith(".json"):
i = p.index("PyMCTranslate/json/") + len("PyMCTranslate/json/")
git.add(p[i:])
local = [
os.path.relpath(p, "PyMCTranslate/json").replace("\\", "/")
for p in glob.iglob("PyMCTranslate/json/**/*.json", recursive=True)
]
for p in local:
if p not in git:
os.remove(os.path.join("PyMCTranslate/json", p))
else:
print("could not find json folder to compare with")