-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_from_dblp.sh
executable file
·100 lines (79 loc) · 2.41 KB
/
add_from_dblp.sh
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
NEW_BIB_FILE=""
function ctrl_c() {
echo "******************************"
echo "\nCleaning up ... \nDeleting ${NEW_BIB_FILE}."
if [ -f "$NEW_BIB_FILE" ]; then
rm ${NEW_BIB_FILE}
fi
# Perform cleanup or other actions here
echo "******************************"
exit 0
}
PYTHON="python3"
PYTHON_VERSION=`$PYTHON --version 2>&1 | awk '{print substr($2,1,1)}'`
$PYTHON --version 2>&1 > /dev/null
if [ $? -ne 0 ]; then
echo "Unknown python version, or python does not exist"
exit
fi
if [ $PYTHON_VERSION -ne 3 ]; then
echo "Please make sure you are using python version 3.x"
exit
fi
# Now this works with python 3
# pip3 install bibtexparser fuzzywuzzy python-Levenshtein
NEW_BIB_FILE=`mktemp temp_library.bib.XXXXXXXXX`
trap ctrl_c INT
$PYTHON scripts/get_bibtex_from_dblp.py --output ${NEW_BIB_FILE}
CUR_PATH=`pwd`
>&2 echo "Executing from \"$CUR_PATH\""
if [ -f "${NEW_BIB_FILE}" ]; then
>&2 echo "Found ${NEW_BIB_FILE} to prepare!"
else
cd ..
CUR_PATH=`pwd`
>&2 echo "Swithcing to \"$CUR_PATH\""
if [ -f "${NEW_BIB_FILE}" ]; then
>&2 echo "Found ${NEW_BIB_FILE}!"
else
>&2 echo "Failed to find ${NEW_BIB_FILE}. Exiting ..."
exit
fi
fi
#Now we know we can find bibtex.bib
MSG=`$PYTHON --version 2>&1`
echo "Using $MSG ..."
# echo "##########################################"
# echo "Ensuring we have the latest library ... "
# echo "##########################################"
# $PYTHON scripts/get_mendeley_library.py
# git pull
# git add library.bib
# git commit -m "Making sure we have the last library"
# git push
# echo "##########################################"
# echo "[ok]"
# echo "##########################################"
# echo
echo "##########################################"
echo "Prepare and upload ${NEW_BIB_FILE} ... "
echo "##########################################"
$PYTHON scripts/prepare_upload_bibtex.py "${NEW_BIB_FILE}" -f
echo "[ok]"
echo
echo "##########################################"
echo "Cleaning up ${NEW_BIB_FILE} ... "
echo "##########################################"
rm $NEW_BIB_FILE
echo "[ok]"
echo
read -p "Do you want to run ./update_all_libs.sh? (y/n): " response
echo "##########################################"
echo "Updating main library ... "
echo "##########################################"
if [[ "$response" == "y" ]]; then
./update_all_libs.sh
fi
echo "[ok]"
echo