-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare_upload_new_bibtex.sh
executable file
·66 lines (49 loc) · 1.42 KB
/
prepare_upload_new_bibtex.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
#!/bin/bash
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=./new.bib
if [ $# -eq 1 ]; then
NEW_BIB_FILE=$1
fi
CUR_PATH=`pwd`
>&2 echo "Executing from \"$CUR_PATH\""
if [ -f "${NEW_BIB_FILE}" ]; then
>&2 echo "Found new.bib to prepare!"
else
cd ..
CUR_PATH=`pwd`
>&2 echo "Swithcing to \"$CUR_PATH\""
if [ -f "${NEW_BIB_FILE}" ]; then
>&2 echo "Found new.bib!"
else
>&2 echo "Failed to find new.bib. 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
$PYTHON scripts/prepare_upload_bibtex.py "${NEW_BIB_FILE}" -f