-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinit.py
More file actions
107 lines (97 loc) · 4.76 KB
/
init.py
File metadata and controls
107 lines (97 loc) · 4.76 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import errno
import fileinput
import fnmatch
import os
import shutil
import sys
def copyDirectory(src, dst):
try:
shutil.copytree(src, dst)
except OSError as exc:
if exc.errno in (errno.ENOTDIR, errno.EINVAL):
shutil.copy(src, dst)
else: raise
def removeDirectory(src):
try:
shutil.rmtree(src)
except OSError as exc:
raise
def mass_replace(directory, file_pattern, search_string, replace_string):
for root, dirs, files in os.walk(directory):
for filename in fnmatch.filter(files, file_pattern):
filepath = os.path.join(root, filename)
with fileinput.FileInput(filepath, inplace=True, backup=False) as file:
for line in file:
print(line.replace(search_string, replace_string), end='')
def doMPRISJava(interactive):
def copyMPRISJava():
if os.path.exists("src/main/java/com/spotifyxp/deps/org"): removeDirectory("src/main/java/com/spotifyxp/deps/org")
copyDirectory("deps/mpris-java/src/main/java/org", "src/main/java/com/spotifyxp/deps/org")
mass_replace("src/main/java/com/spotifyxp/deps/org/mpris", "*.java", "import org.mpris", "import com.spotifyxp.deps.org.mpris")
mass_replace("src/main/java/com/spotifyxp/deps/org/mpris", "*.java", "package org.mpris", "package com.spotifyxp.deps.org.mpris")
if os.path.exists("src/main/java/com/spotifyxp/deps/org"):
if interactive:
inp = input("Overwrite mpris-java? [Y/N]")
if inp.lower().__eq__("y"):
copyMPRISJava()
elif inp.lower().__eq__(""):
copyMPRISJava()
elif inp.lower().__eq__("n"):
return
else:
doMPRISJava(interactive)
else:
copyMPRISJava()
else:
copyMPRISJava()
def doJavaSetupTool(interactive):
def copyJavaSetupTool():
if os.path.exists("src/main/java/com/spotifyxp/deps/de/werwolf2303/javasetuptool"): removeDirectory("src/main/java/com/spotifyxp/deps/de/werwolf2303/javasetuptool")
copyDirectory("deps/JavaSetupTool/src/main/java/de/werwolf2303/javasetuptool", "src/main/java/com/spotifyxp/deps/de/werwolf2303/javasetuptool")
mass_replace("src/main/java/com/spotifyxp/deps/de/werwolf2303/javasetuptool", "*.java", "import de.werwolf2303.javasetuptool", "import com.spotifyxp.deps.de.werwolf2303.javasetuptool")
mass_replace("src/main/java/com/spotifyxp/deps/de/werwolf2303/javasetuptool", "*.java", "package de.werwolf2303.javasetuptool", "package com.spotifyxp.deps.de.werwolf2303.javasetuptool")
mass_replace("src/main/java/com/spotifyxp/deps/de/werwolf2303/javasetuptool", "*.form", "bind-to-class=\"", "bind-to-class=\"com.spotifyxp.deps.")
mass_replace("src/main/java/com/spotifyxp/deps/de/werwolf2303/javasetuptool", "*.form", "de.werwolf2303.javasetuptool.swingextensions.JImagePanel", "com.spotifyxp.deps.de.werwolf2303.javasetuptool.swingextensions.JImagePanel")
if os.path.exists("src/main/java/com/spotifyxp/deps/de/werwolf2303/javasetuptool"):
if interactive:
inp = input("Overwrite JavaSetupTool? [Y/N]")
if inp.lower().__eq__("y"):
copyJavaSetupTool()
elif inp.lower().__eq__(""):
copyJavaSetupTool()
elif inp.lower().__eq__("n"):
return
else:
doJavaSetupTool(interactive)
else:
copyJavaSetupTool()
else:
copyJavaSetupTool()
def doVlcj(interactive):
def copyVlcj():
if os.path.exists("src/main/java/com/spotifyxp/deps/uk"): removeDirectory("src/main/java/com/spotifyxp/deps/uk")
copyDirectory("deps/vlcj/src/main/java/uk", "src/main/java/com/spotifyxp/deps/uk")
mass_replace("src/main/java/com/spotifyxp/deps/uk", "*.java", "import uk.co.caprica", "import com.spotifyxp.deps.uk.co.caprica")
mass_replace("src/main/java/com/spotifyxp/deps/uk", "*.java", "import static uk.co.caprica", "import static com.spotifyxp.deps.uk.co.caprica")
mass_replace("src/main/java/com/spotifyxp/deps/uk", "*.java", "package uk.co.caprica", "package com.spotifyxp.deps.uk.co.caprica")
if os.path.exists("src/main/java/com/spotifyxp/deps/uk"):
if interactive:
inp = input("Overwrite vlcj? [Y/N]")
if inp.lower().__eq__("y"):
copyVlcj()
elif inp.lower().__eq__(""):
copyVlcj()
elif inp.lower().__eq__("n"):
return
else:
doVlcj(interactive)
else:
copyVlcj()
else:
copyVlcj()
def doInit(interactive=False):
doMPRISJava(interactive)
doJavaSetupTool(interactive)
doVlcj(interactive)
if __name__ == '__main__':
doInit(True)