#!/usr/bin/python3
import os
import subprocess

projectName = os.getcwd().split("/")[-1]

print("Working on project "+projectName)

print("Setup directory structure")
subprocess.call("svn rm branches tags trunk", shell=True)  
subprocess.call("svn propset svn:externals 'gfx svn://vcs.mathematik.uni-freiburg.de/kebekus/gfx\nbibliography svn://vcs.mathematik.uni-freiburg.de/kebekus/bibliography' .", shell=True)
subprocess.call("svn up", shell=True)

print("Setup templates")
subprocess.call("cp gfx/templates/*.tex .", shell=True)
subprocess.call("mv example.tex "+projectName+".tex", shell=True)
subprocess.call("sed 's/example/"+projectName+"/g' <01.tex >01new.tex", shell=True)
subprocess.call("mv 01new.tex 01.tex", shell=True)
subprocess.call("svn add *.tex", shell=True)
subprocess.call("bash gfx/svn-propset.sh", shell=True)
