-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathooxmldiff
executable file
·56 lines (45 loc) · 855 Bytes
/
ooxmldiff
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
#!/bin/sh
function usage()
{
echo "$0 <file1> <file2> [xmlfile]"
}
function extract()
{
# First unzip all
mkdir -p "$2"
unzip "$1" -d "$2" >/dev/null 2>&1
# Then convert the XML files to PYX
find "$2" -type f | while read F
do
mime=`file -b --mime-type $F`
if [ "z$mime" = "zapplication/xml" ]
then
python `dirname $0`/xml2pyx.py $F $F.pyx
mv $F.pyx $F
fi
done
}
if [ $# != 2 -a $# != 3 ]
then
usage
exit 1
fi
FILE1=$1
FILE2=$2
TMP=/tmp/ooxmldiff
# Extract both files
TMP1=$TMP/`basename "$FILE1"`1
extract "$FILE1" "$TMP1"
TMP2=$TMP/`basename "$FILE2"`2
extract "$FILE2" "$TMP2"
if [ $# == 3 ]
then
TMP1="$TMP1$3"
TMP2="$TMP2$3"
diff -u "$TMP1" "$TMP2"
else
diff -ru "$TMP1" "$TMP2"
fi
# Clean up the whole place
rm -r $TMP
exit 0