This repository has been archived by the owner on Dec 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathconcat.py
executable file
·54 lines (40 loc) · 1.53 KB
/
concat.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
#!/usr/bin/env python3
import subprocess
import sys
import re
def concat_file(files, target) :
subprocess.call(["cat " + files + " > " + target], shell=True)
subprocess.call(["rm " + files], shell=True)
#Only works if there is inly one / in the names of the files.
def replace(files, target) :
if ("/" in target) :
temp = target.index("/")
target = target[: temp] + "\\" + target[temp :]
names = files.split()
for i in range(len(names)) :
if ("/" in names[i]) :
temp = names[i].index("/")
names[i] = names[i][: temp] + "\\" + names[i][temp :]
if (i == 0) :
subprocess.call(["sed -i 's/" + names[0] + "/" + target + "/' index.html"], shell=True)
else :
subprocess.call(["sed -i '/" + names[i] + "/d' index.html"], shell=True)
files = "client/util.js client/players.js client/hud.js client/item.js client/login.js client/main.js client/game.js"
pattern = re.compile("^[H, h]([e,E][L, l][P, p])?")
if (len(sys.argv) == 1) :
print("No arguments given, run with the \"help\" command to find out how to use the sricpt.")
sys.exit(1)
elif (pattern.match(sys.argv[1])) :
print("Usage: 1- input_0 ... input_n output")
print(" 2- output")
print(" .js required at the end of file.")
print(" Second method will use a hardcoded list of files.")
print(" The files given as input WILL be deleted.")
sys.exit(0)
elif (len(sys.argv) > 2) :
files = []
for i in range(1, len(sys.argv) - 1) :
files += (sys.argv[i] + " ")
target = sys.argv[-1]
concat_file(files, target)
replace(files, target)