-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfix_linguist.py
63 lines (56 loc) · 1.4 KB
/
fix_linguist.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
53
54
55
56
57
58
59
60
61
62
63
from glob import glob
ignores="""\
**/haxe/**/*.*
**/haxe/*.*
**/types/**/*.*
**/types/*.*
**/std/**/*.*
**/std/*.*
**/_std/**/*.*
**/_std/*.*
**/sys/**/*.*
**/sys/*.*
**/obj/**/*.*
**/obj/*.*
hl/**/hl/*.*
**/_*/**/*.*
**/_*.*\
""".split("\n");
def realglob(ignores):
G = []
for ig in ignores:
for i in range(0,5):
iig = ig.replace("**/","*/"*i,1);
for j in range(0,5):
ijg = iig.replace("**/","*/"*j);
ggg = glob(ijg);
G += ggg
# print(ig,ijg,ggg);
return G
nof = list(set(realglob(ignores)))
open(".gitattributes",'w').write(
"\n".join([x+" linguist-generated\n"+x+" linguist-detectable=false" for x in nof])
)
allf = """\
*.*
**/*.*
**/**/*.*
**/**/**/*.*
**/**/**/**/*.*\
""".split("\n");
gigf = open(".gitignore",'r').read().split("\n");
gigf = gigf + [x+"/**/*.*" for x in gigf]
gigf = list(set(realglob(gigf)))
yesf = list(set(realglob(allf)))
yesf = [x for x in yesf if x not in nof]
yesf = [x for x in yesf if x not in gigf]
yesf = [x for x in yesf if "docs" not in x]
yesf = [x for x in yesf if "svg" not in x]
yesf = [x for x in yesf if "xml" not in x]
yesf = [x for x in yesf if len(x.split(".")[-1])<3]
open(".gitattributes",'w').write(
"\n".join([x+" linguist-generated\n"+x+" linguist-detectable=false" for x in nof])
+"\n".join([x+" linguist-detectable=true" for x in yesf])
+"\n*.java linguist-language=Java"
+"\n*.cpp linguist-language=C++"
)