forked from JoshStegmaier/sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeneratecontrollersfromtemplate.sh
More file actions
executable file
·61 lines (44 loc) · 1.81 KB
/
generatecontrollersfromtemplate.sh
File metadata and controls
executable file
·61 lines (44 loc) · 1.81 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
#!/bin/bash
# Script to generate controllers from the generated bindings file, and uses template
currdir=`pwd`
dt=`date '+%m/%d/%Y %H:%M:%S'`
echo Starting ${dt}
CDIR=`pwd`
SRCDIR=${CDIR}
GENFOLDER=authorizenet/apicontractsv1.py
CONTROLLERFOLDER=controllerstemporary
SRCLOG=${CDIR}/log/TestSources
CNTLOG=${CDIR}/log/TestControllers
if [ ! -e "${CDIR}/log" ]; then
echo "Creating ${CDIR}/log"
mkdir ${CDIR}/log
else
echo "Deleting existing ${CDIR}/log/*"
rm -rf ${CDIR}/log/*.* > /dev/null
fi
echo Identifying Requests\/Responses to process from "${SRCDIR}/${GENFOLDER}"
grep -i -e "request *=" -e "response *=" ${SRCDIR}/${GENFOLDER} | grep -v _AVS | cut -d= -f1 | egrep -v "^ |\." | sort -u > ${SRCLOG}0.log
echo Getting Unique Request\/Responses
grep -i -e "request *$" -e "response *$" ${SRCLOG}0.log > ${SRCLOG}1.log
echo Identifying Object names
perl -pi -w -e 's/Request *$|Response *$//g;' ${SRCLOG}1.log
sort -u ${SRCLOG}1.log > ${SRCLOG}2.log
# Create backup for later comparison
cp ${SRCLOG}2.log ${SRCLOG}3.log
echo Creating Final List of Request\/Response to generate code
sort -u ${SRCLOG}2.log > ${SRCLOG}.log
# make sure the temporary folder exists
if [ ! -e "${CONTROLLERFOLDER}" ]; then
mkdir ${CONTROLLERFOLDER}
fi
rm -rf ${CONTROLLERFOLDER}/*Controller.py
echo Creating Controllers
for cntrls in `cat ${SRCLOG}.log`
do
echo Generating Code for ${cntrls}Controller.py
cp ${SRCDIR}/script/ControllerTemplate.pyt ${SRCDIR}/${CONTROLLERFOLDER}/${cntrls}Controller.py
perl -pi -w -e "s/APICONTROLLERNAME/$cntrls/g;" ${SRCDIR}/${CONTROLLERFOLDER}/${cntrls}Controller.py
done
cat ${SRCDIR}/script/headertemplate.pyt ${SRCDIR}/${CONTROLLERFOLDER}/*.py > ${SRCDIR}/authorizenet/apicontrollers.new
echo Controllers generated in module: ${SRCDIR}/authorizenet/apicontrollers.py
echo Finished ${dt}