-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathsejongrc
executable file
·50 lines (46 loc) · 1.25 KB
/
sejongrc
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
REFERER="https://ithub.korean.go.kr/user/total/database/corpusManager.do"
USERAGENT="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
COOKIE="html/cookie.txt"
touch "$COOKIE"
mkdir -p html corpus corpus-utf8 download dictionary
curl_post() {
if test -z "$URL"; then
echo "URL is not set"
exit 1
fi
if test -z "$OUTFILE"; then
echo "OUTFILE is not set"
exit 1
fi
if test -z "$DATA"; then
echo "DATA is not set"
exit 1
fi
if test -f "$OUTFILE"; then
echo "${PREFIX}Skip download $DESC ($OUTFILE)"
return
fi
if test -z "$LOGFILE"; then
LOGFILE=/dev/null
fi
if test -f "$OUTFILE"; then
echo "${PREFIX}Download: Skip $DESC ($OUTFILE)"
else
echo "${PREFIX}Download: $DESC ($OUTFILE)"
curl --stderr "$LOGFILE" -v --user-agent "$USERAGENT" --referer $REFERER --cookie $COOKIE --cookie-jar $COOKIE -o "$OUTFILE.tmp" -s "$URL" --data "$DATA"
mv "$OUTFILE.tmp" "$OUTFILE"
fi
}
patch_preexists()
{
INFILE="$1"
DIRNAME=${INFILE%/*}
BASENAME=${INFILE##*/}
PATCHES=${BASENAME%.txt}-*.patch
for file in patches/$PATCHES
do
test -f $file || continue
echo "${PREFIX}patch... $file"
patch -N -d "$DIRNAME" -p1 < $file
done
}