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
| #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
def trt(file_in, file_out):
fp_in=open(file_in, "r")
fp_out=open(file_out, "w")
nom=None
for lig in fp_in:
if "<Location" in lig:
bloc=[]
tete=[]
nom=lig.split("/")[1]
# if
if "</Location" in lig:
bloc.append(lig)
for x in tete + bloc: fp_out.write(x)
fp_out.write("\n")
nom=None
# if
if nom != None:
mots=lig.strip().split(" ")
if mots[0] in ("ProxyPass", "ProxyPassReverse"):
tete.append(
"%s %s %s\n" % (
mots[0],
nom,
" ".join(mots[1:]),
)
)
else:
bloc.append(lig)
# if
# if
# for
fp_in.close()
fp_out.close()
# trt
if __name__ == "__main__":
trt(sys.argv[1], sys.argv[2]) |